terencesim.18
terencesim.18

Reputation: 1

Okhttp JSON Parsing

I'm trying to parse a Json data with the following code:

OkHttpClient client = new OkHttpClient().newBuilder().build();
Request request = new Request.Builder()
                .url("http://datamall2.mytransport.sg/ltaodataservice/BusServices")
                .method("GET", null)
                .addHeader("AccountKey", "XXXX==")
                .addHeader("accept", "application/json")
                .build();
Response response = client.newCall(request).execute();

The two errors that I'm facing are:

error: cannot find symbol method newBuilder()

and

unhandled exception error for .execute();.

Upvotes: 0

Views: 496

Answers (1)

user7922501
user7922501

Reputation: 440

According to https://square.github.io/okhttp/ you just need to do:

OkHttpClient client = new OkHttpClient();

Upvotes: 1

Related Questions