In my Android application, I am using okHttp library. How can I send parameters to the server(api) using the okhttp library? currently I am using the following code to acces
You just need to format the body of the POST before creating the RequestBody
object.
You could do this manually, but I'd suggest you use the MimeCraft library from Square (makers of OkHttp).
In this case you'd need the FormEncoding.Builder class; set the contentType
to "application/x-www-form-urlencoded"
and use add(name, value)
for each key-value pair.