I am making a POST request using Retrofit, call executes successfully on rest client. Also onResponse of call executes but in response body i am getting error
'unicode' object has no attribute 'items'.
What is the reason of this error?
Related
I'm using retrofit for a network request, but I found a very weird situation, so for some reason my object inside of the array always is null, but other properties are correct.
https://i.stack.imgur.com/pmlh7.jpg
https://i.stack.imgur.com/qBDFQ.png
Logs form okhttp:
https://i.stack.imgur.com/I74Wp.png
I'm using Volley to call api but it always returns "Failed" String in the onResponse method.
I checked the request object and response object and they are the same in postman, post man returns result but volley return "Failed".
Here's the call in fragment
And the call using volley
In loopj when i hit a URL nor onSuccess nor onFailure calling that's why my progressDiaog keep on running for infinite time.
Make sure you are implementing the right methods (different onSuccess/onFailure methods have different inputs).
If you are implementing onSuccess with input JSONObject but your WebService is returning a JSONArray, it will not enter there.
In my API server returns HTTP 400 response code if request does not pass validation, and provides detailed message, that should be parsed as the response.
For example:
public class RegistrationResponse {
private String emailError; // Detailed message. Null if no error occured
}
But Robospice (Retrofit + OkHttp) fires onRequestFailure() with message "retrofit.RetrofitError: 400 BAD REQUEST" in this case and, of course, does not parse anything.
How should I make it parse the response in case if response code is not 2XX?
You should declare Retrofit methods that return HTTP Response objects and check the raw object in your loadDataFromNetwork() for the status you need. This way, however, you will skip the out-of-the-box functionality of parsing responses and will have to do that manually.
Therefore, you should also find a way to reuse the Converter passed to your RestAdapter in the RetrofitSpiceService. Overriding the RetrofitSpiceService#createConverter() method is probably the simplest way to achieve this.
I want to call http request using get method with passing json parameter to get request call.so what will be the proper way to call http get method with passing json request.
http://plaincodesource.blogspot.com/2010/10/android-post.html try this. I believe you can set reauest method "GET" and then write your json into output stream.