How do I update the public read-write OData feed at services.odata.org?

237 views Asked by At

I am currently trying to get a simple demo going of a crud app using the public OData feed at http://services.odata.org/V4/(S(jskq43fsvrxbzaf2jzhboo13))/OData/OData.svc/Products

GET-ting data works, however I am unable to update the data by clicking the button, and get a 501 (Not Implemented) error. I believe it deals with the need to enable CORS. Please see my fiddle. Thanks in advance!

var requestSettings = {
  url: "http://services.odata.org/V3/(S(ettihtez1pypsghekhjamb1u))/OData/OData.svc/Products(" + key + ")",
  method: "POST",
  headers: {
    "X-Http-Method": "PATCH",
    'accept': "application/json;odata=verbose"
  },
  'contentType': "application/json; charset=utf-8", //content-length not required
  datatype: 'json',
  data: JSON.stringify(values),
  success: function updateSuccess() {
    deferred.resolve();
    alert("successful update");
  },
  error: function updateError() {
    deferred.reject();
    alert("un-successful update");
  }
};

$.ajax(requestSettings);

I have a JSFiddle here: https://jsfiddle.net/jf713jf/ybLg1b4h/4/

1

There are 1 answers

6
seteh On

Consider to use DevExpress.data.ODataStore that provides logic to access OData service.

Since you're working with fourth version of OData service, the ODataStore constructor options would like that:

new DevExpress.data.ODataStore({
    url: "http://services.odata.org/V4/(S(jskq43fsvrxbzaf2jzhboo13))/OData/OData.svc/Products",
    key: "ID",
    keyType: "Int32",
    version: 4,

    // To overcome the cross-origin issue
    jsonp: true
});

Hope it helps.