cancel
Showing results for 
Search instead for 
Did you mean: 

API_Sales_Order Post - working with Odata $batch

lmonteroquero
Explorer
0 Kudos

Hi, experts

Trying to do Post with batching functionality.. https://myXXXX.s4hana.ondemand.com:443/sap/opu/odata/sap/API_SALES_ORDER_SRV/$batch

I get this error when sending "The Data Services Request could not be understood due to malformed syntax".. What am I doing wrong ?

Headers

authorization basic authorization.. user and password

content-type multipart/mixed; boundary=batch_mybatch

xcsrf-token token given body

body payload

--batch_mybatch

Content-Type: multipart/mixed; boundary=changeset_mychangeset

--changeset_mychangeset

Content-Type: application/http

Content-Transfer-Encoding: binary

 

POST A_SalesOrder HTTP/1.1

Content-Type: application/json

{

"SalesOrderType": "OR",

"SalesOrganization": "2410",

"DistributionChannel": "10",

"OrganizationDivision": "01",

"SoldToParty": "CUSTOMER-1",

"TransactionCurrency": "EUR",

"SDDocumentReason": "Z01",

"to_Item": {

"results": [

{

"Material": "P121000",

"RequestedQuantity": "1",

"RequestedQuantityUnit": "PI",

"to_PricingElement": {

"results": [{

"ConditionType": "PMP0",

"ConditionRateValue": "150.00",

"ConditionCurrency": "EUR"

}

]

}

},

{

"Material": "P122000",

"RequestedQuantity": "1",

"RequestedQuantityUnit": "PI",

"to_PricingElement": {

"results": [{

"ConditionType": "PMP0",

"ConditionRateValue": "180.00",

"ConditionCurrency": "EUR"

}

]

}

}

]

}

}

--changeset_mychangeset1

--batch_mybatch--

Accepted Solutions (1)

Accepted Solutions (1)

MartyMcCormick
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Luis

Can you please review SAP Note 1869434 https://launchpad.support.sap.com/#/notes/1869434 ? It provides details on the exact spacing required for your payload in terms of carriage returns and other items. It's not clear from your post if you actually have the carriage returns but it looks like you don't. $batch format is extremely picky with regards to syntax. Also, how are you passing this batch call? Using Postman?

Thanks,

Marty

lmonteroquero
Explorer
0 Kudos

Hi.. yes, I am using postman.. any suggestion? Thanks

MartyMcCormick
Product and Topic Expert
Product and Topic Expert
0 Kudos

Please confirm first that you have all of the carriage returns. It doesn't look like you do from your original post and I suspect that is your issue.

cdias
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Luis,

To help you get this sorted I have attached an a example of a $batch request for the Purchase Order OData service. The payload structure is the same so you can use it for your sales orders operation. Like Marty said the format is very sensitive to spaces and carriage returns. So please make sure you have all in the right place.

Thanks.

lmonteroquero
Explorer
0 Kudos

Hi Carlos, thanks for helping with your comments and the example file.. I´m going to try. Thanks

Answers (3)

Answers (3)

lmonteroquero
Explorer
0 Kudos

hI.. finally I achieved it !!! thanks , guys.. I really appreciate 🙂

former_member620438
Discoverer
0 Kudos

Hi Luiz,

Could you please share how did you achieve it?

Thanks in advance!

MartyMcCormick
Product and Topic Expert
Product and Topic Expert
0 Kudos

Carriage return means press the enter key. For example, the end of your payload looks like this:

--changeset_mychangeset1

--batch_mybatch--

But if you look at the note you are missing the trailing dashes on changeset line and a return. Should be something like this:

---changeset_mychangeset1--

--batch_mybatch--

Thanks,

Marty

lmonteroquero
Explorer
0 Kudos

Hi Marty, and thanks for your help.. after reviewing your comments and SAP note, I think I´ve fixed "syntax" issues, but now I get this new message error" ( unknow internal server error ?? ).. any suggestion ?

https://myXXXXX.s4hana.ondemand.com:443/sap/opu/odata/sap/API_SALES_ORDER_SRV/$batch

I attached my file with sent payload if helps..

xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

0050569259751EE4BA9710043F8A5115

In the context of Data Services an unknown internal server error occurred

xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

F97AA2948EBB0240E005C67CB4F73EBC

20190315101510.7966560

For backend administrators: use ADT feed reader "SAP Gateway Error Log" or run transaction /IWFND/ERROR_LOG on SAP Gateway hub system and search for entries with the timestamp above for more details

See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)

lmonteroquero
Explorer
0 Kudos

Hi, sorry, I dont understand "carriage" matter.. and dont know how to check it if I have all of them.. I´m a desperate man 🙂

cdias
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Luis,

A CR is just a change of line in file.

/cd