My Url is
When I use this code the response code is always 500.
Interface Code
@Headers({ "Content-Type: application/json;charset=UTF-8"})
@PATCH("customers/{custId}")
Call<GeoTag> postGeoTagData (@Body geoTagUserData geoTag, @Path("custId") String id, @Header("Authorization") String auth);
In Activity
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(" http://sales.erprnd.com/api/v2/")
.addConverterFactory(GsonConverterFactory.create())
.build();
ApiInterface apiInterface = retrofit.create(ApiInterface.class);
Call<GeoTag> geoTagCall = apiInterface.postGeoTagData(geoTagUserData, CustCode, "Bearer "+body.getToken() );
geoTagCall.enqueue(new Callback<GeoTag>() {
@Override
public void onResponse(Call<GeoTag> call, Response<GeoTag> response) {
Toast.makeText(GeoTaggingActivity.this, ""+response.code(), Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Call<GeoTag> call, Throwable t) {
Toast.makeText(GeoTaggingActivity.this, "Failed", Toast.LENGTH_SHORT).show();
}
});
When I use Postman the response is 201 AND Response IS {} which is ok. My jsonObject is
{
"latitude":11.22,
"longitude":22.11,
"alt_address":"test address",
"height":"12 ft",
"width":"24 ft",
"photo": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAAD"
}
I Have created another class where i get all information from user which is geoTagUserData i get all the info perfectly
Please Help me find the error .
Finally I got The Solution which is, When I Send Data to Send Data to server from My App it just get the value against every field form geoTagUserData Class it doesn't @post
Converted Data in JSON
Format. When My Server Find That I just Values Not In JSON
Format Then It Just Rejected And Return 500 error
So, My solution is just Using Gson Converter get The value form user and Converted it to
JSON
object. and Send That to Server Which will Return 201
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.