Skip to Content

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

POST Data to .xsodata won't work bec. Access-Control-Allow-Origin - CORS is set up

Ladies and Gentlemen,

I'm going slightly mad - I ran into an HANA issue I can't solve - already spent countless days (and some nights...) - no luck so far.

I want to read and write data from/to my HANA Cloud Platform via AJAX requests from another machine.

When I first started I got the usual "Access-Control-Allow-Origin" error in the browser's console when trying to GET data, but after filling out all the required fields in the XS-Admin tool it worked fine, here are my settings:

Allowed Origins:


Allowed Headers:

Origin, Content-Type, Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control

Exposed Headers:


Allowed Methods:


So, I got the access via default $.get() working, no problem.

Strange thing is, when I try to POST data to the .xsodata now with the following code (please note that MY_HCP and MY_OTHER_MACHINE are placeholders of course)

var oEntry = new Object();
oEntry.XXX = "AAA";
     url: "",
     type: "POST",
     dataType: "json",
     data: JSON.stringify(oEntry),
     async: true,
     cache: false,
     beforeSend: function(xhr) {
          xhr.setRequestHeader("Content-Type", "application/json;odata=verbose;charset=utf-8");
          xhr.setRequestHeader("DataServiceVersion", "2.0");
          xhr.setRequestHeader("Accept", "application/json");
     success: function() {
     error: function() {
          console.log("Error occured");

I still receive the following error:

XMLHttpRequest cannot load No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://MY_OTHER_MACHINE' is therefore not allowed access.

I tried to use

  • application/x-www-form-urlencoded
  • multipart/form-data
  • text/plain

as well - same error.

Thank you very much in advance, I really appreciate it!

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