odata verbose problem

Jun 26, 2012 at 2:40 PM
Edited Jun 26, 2012 at 2:40 PM



how can I prevent that datajs adds the odata=verbose header to the content type?

I have a service 2.0. who doesn't work with this header.

As OData doesn't 2.0 specify this verbose header value...is this a bug in datajs where it shouldn't append this header value for 2.0 services?

As I see here:
"This content type is used in a request to a data service to request the data service format for the response payload using the application/json; odata=verbose format according to the formatting rules outlined in Verbose JSON format (section A data service MAY support this content type."

But this is for 3.0 only?
Or how can I prevent that datajs modifies the content-type header which I set?
Thanks and best regards

Jun 27, 2012 at 7:16 PM

Hi Joe,

   You can fix the Content-Type header (and pretty much any header) in the request object you pass to OData.request:   

    requestUri: "http://myUrl",
    headers: { 
         "Accept": "application/json",
         "Content-Type:" "application/json"
  function (data, response) {
      // do something interesting with the data
  function (err) {
      // handle the error

    Now, the content type "application/json;odata=verbose" is still application/json, with a parameter that doesn't alter that fact and should be ignored by the endpoint if it doesn't understand it.  Do you happen to know what server implementation the endpoing is using?? (Eg. WCF Data Services, odata4J, etc.)  because seems to me that it is doing a string comparison against the content-type header in the request instead of parsing it to extract the mime type and the parameters.


Alex Trigo. 


Jun 28, 2012 at 3:34 PM
Edited Jun 28, 2012 at 3:35 PM

Thanks Alex,

that worked nicely :D

The endpoint I tested was a SAP OData Gateway service who apparently doesn't ignore this header.