I am using retrofit 2.1.0
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
In API Interface,
@FormUrlEncoded
@POST("employeerest")
Call<EmployeeInfo> getEmployeeInfo(@Field("ActivationCode") String strActivationCode,
@Field("Data") String strjsonData);
Problem is retrofit change String value of strjsonData.
Actual value is : ODk0MTUxODc3ODk2ODI2OURs2YIUf6zveGI5P+bQR4phRk34OdAxZTuOI97tgzDekU7jTWfVAqjEex8zHn9xgOA1UxA3CCV7VXmAzrU1z4T5PyS+czPKCAd2HbdsNdvorHBQEZwjpADdbVY1M5xPrNWb3L910MuHjex6NSVoFFdxn3fAlwRtYQbseHS3GZCIssyv4g==
While Retrofit replace its value to : ODk0MTUxODc3ODk2ODI2OURs2YIUf6zveGI5P%2BbQR4phRk34OdAxZTuOI97tgzDekU7jTWfVAqjE%0Aex8zHn9xgOA1UxA3CCV7VXmAzrU1z4T5PyS%2BczPKCAd2HbdsNdvorHBQEZwjpADdbVY1M5xPrNWb%0A3L910MuHjex6NSVoFFdxn3fAlwRtYQbseHS3GZCIssyv4g%3D%3D%0A
Can anyone suugest me where I am wrong ? Please help me.. Thanks in advance.
Finally solve the problem.
Create list of namevalue pair from my side rather then Retrofitside and send it.
List<NameValuePair> nameValuePair = new ArrayList<NameValuePair>();
nameValuePair.add(new BasicNameValuePair("ActivationCode",
strActivationCode));
nameValuePair.add(new BasicNameValuePair("Data", base64));
Call<EmployeeInfo> call = null;
try {
call = NetworkConstants.getNetworkObject().loginUser(getQuery(nameValuePair));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
private String getQuery(List<NameValuePair> params)
throws UnsupportedEncodingException {
StringBuilder result = new StringBuilder();
boolean first = true;
for (NameValuePair pair : params) {
if (first) {
first = false;
} else {
result.append("&");
}
result.append(pair.getName());
result.append("=");
result.append(pair.getValue());
}
return result.toString();
}
and in interface
@POST("myapi")
Call<EmployeeInfo> loginUser(@Body String body);
So its not replacing strings.