本文来自:http://*.com/questions/21739276/android-volley-gives-me-400-error
本人是根据文中的其中一方法:
I had the same problem and i removed from the header:
headers.put("Content-Type", "application/json");
now it works great!
以下是全文
I'm trying to make a
I get the following error:
I have seen a lot of examples and I don't really see what is going wrong here. Anyone any idea? I updated the code with this method:
and changed
Still getting the same error! |
|||||||||||||||||||||
|
I had the same problem and i removed from the header:
now it works great!
|
|||||
|
400 indicates a bad request, maybe you're missing |
|||||||||||||||||||||
|
I've got this error and now Iit's been fixed. I did what is told in this link. What you need to do is
with
Hope this helps. |
||||
I have removed this params.put("Content-Type", "application/x-www-form-urlencoded"); This is my Code Change.
|
|||
I have the same issue before and I got the solution in my project:
In the code Snippet above I used Post Method: My answer is base on my experience and so take note: 1.) When using POST method use "StringRequest" instead of "JsonObjectRequest" 2.) inside getHeaders Override the value with an Empty HashMap
And everything works in my case. |
|||
In Android 2.3 there is a problem using Base64.encodeToString() as it introduces a new line in HTTP header. See my response to this question here in SO. Short answer: Don't use Base64.encodeToString() but put the already encoded String there. |
||||
400 error is because Content-Type is set wrong. Please do the following.
|
|||
There can be multiple reasons for this error. One ofcouse as said by others is, maybe you are missing or have improperly set 'Content-type' header. If you are properly implemented that, other possible reason is that you are sending params directly from your url. There may be a case when params is a string with some white spaces in it. These white spaces cause problem in GET requests through volley. You need to find another way around it. Thats all. |
|||||||||
|