mosh91
mosh91

Reputation: 1

How to fix 'class file for okio.ByteString not found¿'?

I'm getting the error on this line RequestBody body = RequestBody.create(json, JSON);

I saw several post about add it manually, so I did it, I include the jar as part of the build path without any change. What would be the correct way to add it on Eclipse?

I'm using okhttp-4.12.0 and okio-3.7.0

I copied the code from the official web, I also added to build path the okio-3.7.0.jar but it looks like is not detecting or not relating the libraries.

This is the code I'm using:

MediaType JSON = MediaType.get("application/json");

        OkHttpClient client = new OkHttpClient();
        RequestBody body = RequestBody.create(json, JSON);
        Request request = new Request.Builder().url(hostURL + url).post(body).build();
        try (Response response = client.newCall(request).execute()) {
            return response.body().string();
        }

Upvotes: 0

Views: 294

Answers (0)

Related Questions