webservice is throwing 400 Bad request when sending certain characters in post body?

Jens Bergvall picture Jens Bergvall · Mar 12, 2012 · Viewed 7.3k times · Source

I currently have a webservice running on a server somewhere, and if i access the webservice locally i can type in anything and it takes the inputs without any problem.

However, when trying to make a http-post to the webservice from the outside with inputs containing chars such as '&' in this scenario, i run into http error 400 -Bad request.

The below screenshot is a screenshot of the google-chrome addon/in poster, which allows me to make posts to my server.

So, what i'm trying to figure out is why the server doesnt like the request when special characters are part of the inputs.

Chrome addon Poster

Any ideas/tips and/or pointers will be highly appreciated.

Thanks in advance.

Edit: Please assume that i have a function in the webservice that recieves a string as input.

Answer

jerrymouse picture jerrymouse · Mar 12, 2012

Probably the text is not properly urlencoded. If you are using GET protocol, the query becomes:

?bar1=12345&&bar2=something

Try sanitizing (urlencode) string before negotiating with your webservice.