Can we specify the character encoding of parameters in a POST request with a application/x-www-form-urlencoded
content type in an API (e.g. RESTful web service), and if "Yes", how?
The parameters will be encoded according the algorithm specified here: URL-encoded form data
Before strings can be percent-encoded (which operates on bytes), they need to be represented as a stream of code units with a particular character encoding.
For Forms, this character encoding can be determined by the Form attributes sent from the server, for example through a hidden _charset_
entry in the form data set or an accept-charset
attribute.
However, since an API request doesn't have a corresponding Form, we cannot deduce the character encoding which is accepted/desired by the server.
It seems, the only reasonable encoding is UTF-8. This is the default encoding when no such character encoding can be determined from the Form.
(Related question) (but no duplicate)