Add query params to a GET request in okhttp in Android -


is there way add query params (?param1=val1&param2=val2) request using okhttp in android?

i looking api , not manually adding params in loop , escaping values.

try httpurl class (in okhttp package).


//adds pre-encoded query parameter url's query string addencodedqueryparameter(string encodedname, string encodedvalue)  //encodes query parameter using utf-8 , adds url's query string addqueryparameter(string name, string value) 

note: if there name/value pairs name, these functions add pair


setencodedqueryparameter(string encodedname, string encodedvalue)  setqueryparameter(string name, string value) 

note: if there name/value pairs name, these functions remove them , after add new pair


example:

httpurl url = new httpurl.builder()     .scheme("https")     .host("www.google.com")     .addpathsegment("search")     .addqueryparameter("q", "polar bears")     .build(); 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -