Skip to Content

Escape special characters for OData response

Hi all,

I'm facing a problem on HTTP response when some special characters are in my entity fields.

For example I've got a Edm.String field which has characters like ###, ", < (two number signs ## are ok, but three invoke an error)

When I set output format to xml via URI parameter $format=xml, I get following error:

<message xml:lang="en">In the context of Data Services an unknown internal server error occured</message>

Exception /IWCOR/CX_DS_INTERNAL_ERROR in class /IWCOR/CL_DS_EP_WRITER_OUTPUT method /IWCOR/IF_DS_EP_WRITER_OUTPUT~WRITE and Line 39

If I use JSON as output format, HTTP response code is 200!!, but payload just ends on the character which cannot be interpreted:

(ABAP)-JSON generator can handle double quotes much better than XML format:

How can I escape these output strings, without adding chars which will appear in response payload?

Thanks,

Steffen

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Mar 19, 2014 at 11:03 AM

    Hi Steffen,

    I think the ### are just placeholders for binary data. Unfortunately the screenshot of the debugger doesn't show the right part, where we could see the real content.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Steffen Froehlich

      Hi Steffen,

      Yes that's true. As a lot of unit testing is done in the GW client or browser tools, we forget about escaping as 99% of the time non-escaped data works. In general, any "programmatic" consumer client should escape the request URI and the body (this is another possible fault when posting/putting from a browser test case, e.g. ampersand in a body text that is not escaped ).

      The entity feeds from the OData parser are escaped as part of the process so it's not really necessary to have to escape anything on the application level.

      Cheers

      Ron.