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:
access-control-allow-headers,access-control-allow-origin,access-control-expose-headers,authorization
Allowed Methods:
GET HEAD POST OPTIONS PUT DELETE TRACE CONNECT
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"; jQuery.ajax({ url: "https://MY_HCP.ondemand.com/data/test.xsodata/TEST", 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() { console.log("Success!"); }, error: function() { console.log("Error occured"); } });
I still receive the following error:
XMLHttpRequest cannot load https://MY_HCP.ondemand.com/data/test.xsodata/TEST. 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!