I have a JSONObject:
{user:{"firstname":"testuser","surname":"æøå"}}
So i have these special characters in the object
I URLEncode the jsonString i have.
urlEncodedJsonReq = URLEncoder.encode("{user:{\"firstname\":\"testuser\",\"surname\":\"æøå\"}}","UTF-8");
I get a response from the server: "The URI you submitted has disallowed characters.".
This is the encoded url: serverurl/%7Buser%3A%7B%22firstname%22%3A%22testuser%22%2C%22surname%22%3A%22%C3%A6%C3%B8%C3%A5%22%7D%7D
But what i need it to be:
%7Buser:%7B%22firstname%22:%22testuser%22%2C%22surname%22:%22%C3%A6%C3%B8%C3%A5%22%7D%7D
Is this possible in any reasonable way?
Thanks in advance
If you want to include a colon as it is within a REST query URL, escape it by url encoding it into %3A .
Colon IS an invalid character in URL unless it is used for its purpose (for eg http://). "...Only alphanumerics [0-9a-zA-Z], the special characters "$-_. +! *'()," [not including the quotes - ed], and reserved characters used for their reserved purposes may be used unencoded within a URL."
It is completely fine to use a colon : in a URL path.
Yes, or simply:
URLEncoder.encode(theUrl).replace("%3A", ":");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With