Reputation: 1
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
Reputation: 440
According to https://square.github.io/okhttp/ you just need to do:
OkHttpClient client = new OkHttpClient();
Upvotes: 1