Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

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.

Tags:
Former Member

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question