on 08-27-2014 4:39 PM
How to send xml data to post odata using sapui5 , I am trying to send data to server using x-csrf token and data in the form of xml.. If I try to send it in json format it is being submitted but since the server is not accepting I should only submit xml
OData.request
({
//posting data
requestUri: "proxy/http/server:8000/sap/opu/odata/sap/ZCUST_TESTING_SRV/post_cust",
method: "PUT",
headers: {
"X-Requested-With": "XMLHttpRequest",
"Content-Type": "application/xml",
"DataServiceVersion": "2.0",
"X-CSRF-Token":header_xcsrf_token
},//xml data
data :
'<?xml version="1.0" encoding="utf-8"?>'+
'<entry xml:base="http://server:8000/sap/opu/odata/sap/ZCUST_TESTING_SRV/"'+
'xmlns="http://www.w3.org/2005/Atom"'+
'xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"'+
'xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">'+
'<content type="application/xml">'+
'<m:properties>'+
'<d:Kunnr>56567696</d:Kunnr>'+
'<d:Land1>144</d:Land1>'+
'<d:Name1>STARK</d:Name1>'+
'<d:Name2>SAMPLE </d:Name2>'+
'<d:Ort01>STARKEXPO</d:Ort01>'+
'<d:Pstlz>X</d:Pstlz>'+
'<d:EStatus>X</d:EStatus>'+
'</m:properties>'+
'</content>'+
'</entry>'
});
alert("posted");
}
);
Is it the way to send data. I am able to send as json but Is there anyway to send in the form of xml
You seem to have submitted this exact same question in FIVE OTHER LOCATIONS too:
javascript - Unable to post xml odata by using sapui5 - Stack Overflow
and
javascript - How to send xml odata to server using sapui5 - Stack Overflow
and
and in a comment here:
and in another comment in the same thread here:
Please stop doing this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you create a request through ui5 oData Model, it converts the request body into xml which you don't have to worry. The oData model instance has to be created as,
var oModel = new sap.ui.model.odata.ODataModel(url,false); // false --> XML
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.