on 07-10-2014 3:32 PM
Hello Everyone,
I tried creating a service that use Deep entity to post some data to SAP. That works well from test service option, but when i am trying to code from java script it is failing and getting" Http Request failed "
Following is the snippet i use for my testing to pass the data, is there anything wrong with my passing of parameters, please suggest.
var itemO = [{ID:24, Name:"xyz"}, {ID:45,Name:"tze"}];
var itemT = [{ID:24, Name:"xyz"}, {ID:45,Name:"tze"}];
var head = [{ID:24, Name1:"xyz", Name2:"abc"}];
var headerCont = [{Header:head, HeadItemT:itemT, HeadItemO:itemO}]
alert(requestUri);
var request =
{ headers: {"X-Requested-With": "XMLHttpRequest",
"Accept": "application/atom+xml,application/atomsvc+xml,application/xml",
"Content-Type": "application/atom+xml",
"DataServiceVersion": "2.0" },
requestUri: requestUri,
method: "POST",
user: "user123",
password: "welcome",
data: headerCont };
// Send the request and define callback methods.
OData.read(
requestUri,
function (data) {
var html = "";
for (var i = 0; i < data.results.length; i++) {
alert("Hello" + data.results[i].ID;
}
document.getElementById("container").innerHTML = html;
},
function (err) {
alert("Error occurred " + err.message);
}
);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
var request =
{ headers: {"X-Requested-With": "XMLHttpRequest",
"Accept": "application/atom+xml,application/atomsvc+xml,application/xml",
"Content-Type": "application/atom+xml",
"DataServiceVersion": "2.0" },
requestUri: requestUri,
method: "POST",
user: "user123",
password: "welcome",
data: headerCont };
Is it not sufficient to post or am i missing something. Also i followed the above thread and
not sure i can use this in my native application as it is not SAP UI5 based.
oModel = new sap.ui.model.odata.ODataModel('<URL>');
what will be the way to get the model instance if it is javascript, is there any place where i can refer the documentation for Ajax. Thank you for the feedback.
Hi Vijay,
you can refer Ajax documentation at jQuery.post() | jQuery API Documentation and jQuery AJAX get() and post() Methods
Regards,
Chandra
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.