I\'m trying to pass a string of the format below as the body of a http post request.
param1=PARAM1¶m2=PARAM2¶m3=PARAM3
But
To answer the question directly, you can use TypedString
as the method parameter type. The reason the value is being changed is because Retrofit is handing the String
to Gson in order to encode as JSON. Using TypedString
or any TypedOutput
subclass will prevent this behavior, basically telling Retrofit you will handle creating the direct request body yourself.
However, that format of payload is called form URL encoding. Retrofit has native support for it. Your method declaration should actually look like this:
@FormUrlEncoded
@POST("/oauth/token")
void getAccessToken(
@Field("param1") String param1,
@Field("param2") String param2,
@Field("param3") String param3,
Callback callback);