Java – how to add query parameters to HTTP get requests through okhttp?
I am using the latest okhttp version: okhttp-2.3 0.jar
How to add query parameters to get requests in okhttp in Java?
I found a related question about Android, but I didn't answer here!
Solution
As mentioned in another answer, okhttp v2 4 provides new functions, which makes it possible
see http://square.github.io/okhttp/2.x/okhttp/com/squareup/okhttp/HttpUrl.Builder.html#addQueryParameter -java. lang.String-java. lang.String-
This is impossible. The current version of okhttp, there is no method provided that will handle this for you
The best thing is to create a URL string or URL object (found in Java. Net. URL) that contains its own query and pass it to the okhttp request builder
As you can see, request Builder can use strings or URLs
An example of how to build a URL can be found in what is the idiomatic way to compose a URL or URI in Java? find