locked
OData CRUD operations RRS feed

  • Question

  • Hello gyus,

    I'm wondering if anybody can give some examples of Ajax code for updating or deleting records via the AX 2016 OData CRUD operations.

    I have my data entity set up and I can load the data successfully via the "GET" http request, but couldn't update or delete any records by sending "POST" or "DELETE" http request.

    For example, with the code below, I'm hoping my browser will send a request with "DELETE" method, but actually my IE 11 will send a "POST" and I would get 403 Forbidden error in the http response. The url "/data/MyEntityCollectionName" is where it loads the OData with no issues.

    Request Header: POST /data/MyEntityCollectionName HTTP/1.1

    $.ajax({
      url: baseUrl,
      type: "DELETE",
      dataType: "json",
      success: function(result) {
       options.success(result);
      },
      error: function(result) {
       options.error(result);
      }
     });
    },

    btw, I have checked following articles:

    https://ax.help.dynamics.com/en/wiki/dynamics-ax-7-services-technical-concepts-guide/#odata-services

    https://msdn.microsoft.com/en-us/library/gg328025(v=crm.7).aspx#BKMK_SetRequestHeaderHTTPMethodJQUERY

    https://ax.help.dynamics.com/en/wiki/odata-in-dynamics-ax-7/#odata-in-dynamics-ax





    • Edited by Marvin Liu Wednesday, June 22, 2016 11:16 PM correction
    Wednesday, June 22, 2016 11:12 PM

All replies