I experienced a problem with data transmitted to an XData endpoint where there are accented chars (éèà...) in the content.
What is the right way to handle this ?
Request a 'Content-type json; charset=utf-8' header ?

Does XData analyze the body (first bytes) of an incoming request to guess the charset ?

Are you encoding the content as UTF-8? Try to do so, it should work.

The content is sent by a java client I don't have sources of.
I was told by the programmer that he sends utf-8 but I didn't check further.
That's why I asked about adding the charset in content type header

No need, it already assumes utf-8 without charset. I suggest that you first do a detailed inspect to be sure the content is being sent as utf-8.

One thing I forgot to mention: it's not only that accented chars are lost.
The function is of the form: MyFunction (arg: TMyObjectList)

The json passed is like : [{"attr1":"value1", "attr2":"value2"}, {{"attr1":"value1", "attr2":"value2"}]

When values contain accented chars, the parser issues an error :
"code": "TJsonReader.EInvalidStateException",
"message": "Invalid Json parser state. Expected: BeginArray. Actual: EOF"

Well, the JSON you provided is invalid.

Indeed it's a typo in my post :slightly_smiling_face:
The json provided when I have the problem is valid.
The json without an accented char is accepted by the endpoint. The exact same json with an accented char is refused with the error message I previously posted (Expected: begin array. Actual: EOF)

Have you checked if the bytes sent, the raw message, is a valid UTF-8 message? Can you provide the exact content sent by the client?

Just for the record, I had the other side checking that they send UTF-8 (and forcing it).

By the way, this version has brought xdata to an awesome level.

Can't wait for GraphQL now ;o)

1 Like

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.