Skip to Content
0
Jul 26, 2016 at 08:07 AM

OData Create entry - POST error

10138 Views

Hi all,

I succesfully managed update and get operation with OData but i'm facing an error when i try to create a new item in my entity set

First of all, my server side setup.

  • SEGW with entity set and entity

  • The service

  • and the test of the same

Obviously I've implemented the CREATE_ENTITY method with dummy code just to check if it's triggered

METHOD materialsset_create_entity.
   
   er_entity-matnr = 'TResult'.
ENDMETHOD.

In my page I call the Odata in this way

var itemString = "/MaterialsSet/";

var serviceURI = "/sap/opu/odata/sap/ZMATERIALS_SRV";

var username = "User";

var password = "Password";

var oModel = new sap.ui.model.odata.v2.ODataModel(serviceURI, {

user: username,

password: password});

var oEntity = {

"Code": "CodeTest",

"MaterialType": "ROH",

"Description": "Test",

"StandardPrice": 0,

"Currency": "EUR"
};

oModel.create(itemString, oEntity, null, function () {

sap.ui.commons.MessageBox.alert("Success!") ;

}, function () {

sap.ui.commons.MessageBox.alert("Error!");

});

When the page hit my code, the metadata is retrieved succesfully but when i try to create the new entry (this is obviously a test code) i got a 202 as response for the batch

  1. Request URL:https://zzzzz:vvvvv@10.1.1.1/sap/opu/odata/sap/ZMATERIALS_SRV/$batch
  2. Request Method:POST
  3. Status Code:202 Accepted
  1. But the response is

Content-Type: application/http

Content-Length: 341

content-transfer-encoding: binary

HTTP/1.1 500 Internal Server Error

Content-Type: application/json

Content-Length: 225

dataserviceversion: 1.0

{"error":{"code":"CX_SXML_PARSE_ERROR/001560AA0E081DEB8CA398CC1690D406","message":{"lang":"it","value":"Error while parsing an XML stream"},"innererror":{"transactionid":"578CF552A51F7AADE10000000A63040C","errordetails":[]}}}

any idea on how to solve?

Attachments

gat1.png (38.3 kB)
gat2.png (14.1 kB)
gat3.png (47.6 kB)