Does anyone know how we are supposed to call the REST API to store special characters? I have tried the following methods:
- No special handling at all. I noticed Parse can handle special characters such as #@$ etc. so I figured I will give this a shot. This ends up with no luck. sample curl query is:
curl -X POST \
-H "X-Parse-Application-Id: appId" \
-H "X-Parse-REST-API-Key: apikey" \
-H "Content-Type: application/json;" \
-d '{"testString":"é"}' \
https://api.parse.com/1/classes/TestObject
This returns "{"code":107,"error":"The object contained an invalid utf8 string"}" which is sort of expected.
- Then I thought I would add the charset header in the post call, i.e.
curl -X POST \
-H "X-Parse-Application-Id: appId" \
-H "X-Parse-REST-API-Key: apikey" \
-H "Content-Type: application/json; charset=utf-8" \
-d '{"testString":"é"}' \
https://api.parse.com/1/classes/TestObject
This returns same result as the first attempt.
- Okay, then I tried manually encode it to UTF-8, i.e.
curl -X POST \
-H "X-Parse-Application-Id: appId" \
-H "X-Parse-REST-API-Key: apikey" \
-H "Content-Type: application/json; charset=utf-8" \
-d '{"testString":"%C3%A9"}' \
https://api.parse.com/1/classes/TestObject
Now this does create the row, however, the value is literally %C3%A9 as opposed to é. I tried taking out the charset value in the header which didn't seem to help either.
- I noticed everything worked perfect via the data browser. So I monitor the js query to see what db is sending out. It turned out the browser is sending é for é. Then I proceed to change my curl and, tada, I got it, i.e.
curl -X POST \
-H "X-Parse-Application-Id: appId" \
-H "X-Parse-REST-API-Key: apikey" \
-H "Content-Type: application/json; charset=utf-8" \
-d '{"testString":"é"}' \
https://api.parse.com/1/classes/TestObject
Finally gave me what I wanted which is value é.
Now I am puzzled, what kind of encoding converts é into é? I got all sorts of other special foreign characters I need to handle too and I need to find a way to reliably encode them into the expected format...
Thanks in advance!