Unable to post xml odata by using sapui5



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://ift.tt/r5ut6F' "+
"xmlns:m='http://ift.tt/1dtZymv'"+
"xmlns:d='http://ift.tt/1cVQIMf'>"+
"<content type='application/xml'>"+
"<m:properties>"+
"<d:Kunnr>56567676</d:Kunnr>"+
"<d:Land1>144</d:Land1>"+
"<d:Name1>john</d:Name1>"+
"<d:Name2>SAMPLE </d:Name2>"+
"<d:Ort01>johnexpo</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


No comments:

Post a Comment