class CustomTask implements Task {

    @Override
    public void execute(Context ctx) throws Exception {
        // retrieve a variable using the helper class
        String url = ContextUtils.assertString(ctx, "url");


        OkHttpClient client = new OkHttpClient();
        Request req = new Request.Builder()
                .url(url)
                .build();

        try (Response resp = client.newCall(req).execute()) {
            if (!resp.isSuccessful()) {
                log.warn("Error while fetching {}: {}", url, resp.code());
                ctx.setVariable("result", error(resp.code()));
                return;
            }

            ObjectMapper om = new ObjectMapper();
            Object data = om.readValue(resp.body().byteStream(), Object.class);

            // do not use custom classes and data structures when setting variables in a task
            // stick to the default JDK classes to avoid serialization issues
            ctx.setVariable("result", ok(data));
        }
    }

}