on 12-15-2017 7:51 PM
Hey Everyone,
I am trying to get my POST call working using Batch but I am getting an error about my payload. I am new to SAPUI5 and am looking for guidance.
I am getting this error when I make the call from the UI
When I execute the call I am trying to replicate in SAP Gateway Client it looks as so and it works.
--batch
Content-Type: multipart/mixed; boundary=changeset
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
POST SRMShoppingCartItemCollection(NUMBER_INT='0000000001',OBJECT_ID='1004266',DOC_MODE='EDIT',WIID='000000000000')/ItemAccountAssignmentNavigation HTTP/1.1
Content-Type: application/atom+xml
Accept: application/atomsvc+xml;q=0.8, application/json;odata=fullmetadata;q=0.7, application/json;q=0.5, */*;q=0.1
DataServiceVersion: 1.0
MaxDataServiceVersion: 3.0
Content-Length: 372
<a:entry xmlns:a="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"><a:author><a:name/></a:author><a:content type="application/xml"><m:properties><d:NUMBER_INT>0000000001</d:NUMBER_INT><d:OBJECT_ID>1004266</d:OBJECT_ID></m:properties></a:content></a:entry>
--changeset--
--batch--
However, When I try to submit through my custom exit in BATCH I am unsure how I am to submit the BODY of the payload?
var sServiceUrlBatch = "/sap/opu/odata/srmnxp/SRMSHOPPING_CART/";
//var metadata = Appcc.getMetadata("accAssignment");
var view = controller.getView();
var assetList = [];
var that = view.getController();
var batchModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/srmnxp/SRMSHOPPING_CART/", true);
var batchChanges = [];
var json2 = {
number_int : "0000000001",
object_id : 1004277,
}
for ( var k = 0; k < 2; k++ ) {
batchChanges.push(batchModel.createBatchOperation("SRMShoppingCartItemCollection(NUMBER_INT='0000000001',OBJECT_ID='1004277',DOC_MODE='EDIT',WIID='000000000000')/ItemAccountAssignmentNavigation", "POST", json2) );
}
batchModel.addBatchChangeOperations(batchChanges);
batchModel.submitBatch();
batchModel.refresh();
How can I put my JSON2 variable in the correct format that the gateway call is looking for?
error for XML stream parsing is a generic error which occurs when the data type and field values in payload are incongruent. In your case I see at one place OBJECT_ID is in quotes while at another it's not? Also such error can occur if the name of property is different in actual payload and metadata.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ankit,
Thanks for your answer. I had Object_ID not in quotes as it did not have quotes when I tested in SAP Gateway client.
However, adding them made it work! 🙂
Here is the updated solution that works.
var sServiceUrlBatch = "/sap/opu/odata/srmnxp/SRMSHOPPING_CART/";
var view = controller.getView();
var assetList = [];
var that = view.getController();
var batchModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/srmnxp/SRMSHOPPING_CART/", true);
var batchChanges = [];
var json2 = {
NUMBER_INT : "0000000001",
OBJECT_ID : "1004277",
DOC_MODE : "EDIT",
WIID : "000000000000",
}
for ( var k = 0; k < 2; k++ ) {
batchChanges.push(batchModel.createBatchOperation("SRMShoppingCartItemCollection(NUMBER_INT='0000000001',OBJECT_ID='1004277',DOC_MODE='EDIT',WIID='000000000000')/ItemAccountAssignmentNavigation", "POST", json2) );
}
batchModel.addBatchChangeOperations(batchChanges);
batchModel.submitBatch();
batchModel.refresh();
Hi Keith Warnock,
As per my understanding, you are committing some mistake in your HTTP Request, as even a extra space can cause errors.
Regards,
Arjun Biswas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.