Skip to Content
avatar image
Former Member

Setting Accept Request Header on ODataModel

Hi, SCN.

I noticed in the OpenUI5 JsDoc Report that some headers are not modifiable by mHeaders when specifying a new sap.ui.model.odata.ODataModel object. These headers are: accept, accept-language, x-csrf-token, MaxDataServiceVersion, DataServiceVersion. Is it possible to adjust the Accept header when binding to my service URL?

Let's say I need to also interface with an ASP.NET WebAPI OData Service (using v1-3 OData packages). I can set my Accept header to "application/json;odata=verbose" in order to return results in a verbose JSON format that OData v2 supports. By default, my OData v3 service will return a "JSON light" response, which causes an endless loop of GET requests to my service from the UI5 library.

Thanks,

Mitch

As an alternative, I can set my custom service to properly return JSON response based on MaxDataServiceVersion. This should be handled out-of-the-box from a v1-3 OData package, but unfortunately ASP.NET Web API OData does not support OData v2. I can handle this with a custom message handler, but that is out of scope for this request, and I already have a solution there. I would rather find a way to set Accept header from my client for the time being.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Aug 20, 2015 at 10:54 PM

    Hi, Barry.

    I'm facing the same situation where I'm trying to integrate a .Net Odata service and running into endless loop. What was your alternative to overcome this.

    Appreciate your help.

    Thanks,

    Srini.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      While I was able to solve from server-side, in the scenario where you are unable to alter the API, it would be nice to have the ability to modify accept in the v2.ODataModel.