Reputation: 697
I understand with GET request they need to be entered into a URL and therefore need to be URL (percent) encoded so that they don't mean anything in the context of a server interpreting the URL.
But if data is in the body of a request rather than the URL then why does it need to be URL encoded?
Example:
Upvotes: 14
Views: 9609
Reputation: 24712
You can have any format you want in the body of a POST request. You should just make sure that the receiving end (server) accepts that format and knows how to handle that.
URL-encoding (application/x-www-form-urlencoded
Content-Type) is frequently used because it is the default format of data when submitting an HTML <form>
in web pages and because most servers know how to handle it.
So, as comments said, the data in your POST body need to be url-encoded because you/browser/agent have specified the HTTP Content-Type: application/x-www-form-urlencoded
header.
Upvotes: 1