Skip to Content
0

Not able to post sales order with items using odata interface - Bad Request response

Sep 05, 2017 at 10:04 PM

98

avatar image
Former Member

Hi Experts,

Am trying post sales order with item using odata import service and getting "Bad request" response error.

Import service used:

https://host-api.s4hana.ondemand.com/sap/opu/odata/sap/CUAN_IMPORT_SRV/ImportHeaders

Method: Post

Example request:

{

"data": {

"Interactions": [

{ "CommunicationMedium" : "BUSINESS_DOCUMENT",

"ContactId" : "xyz@gmail.com",

"ContactIdOrigin" : "EMAIL",

"InteractionType" : "SALES_ORDER",

"IsAnonymous" : "false",

"Timestamp" : "/Date(20170801222212)/",

"Currency" : "DKK",

"Amount" : "250",

"Products" : [

{ "ItemId" : "354290",

"Quantity": "2",

"Currency" : "DKK",

"Amount": "100",

"Name": "TEST"

}

]

}

]

}

}

Response:

"The Data Services Request could not be understood due to malformed syntax"

Could you please let me know if am missing something in request.

Thanks and regards,

Dinesh.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
avatar image
Former Member Sep 05, 2017 at 11:49 PM
0

Dear Dinesh,

I think you are missing the ItemType in your products, which is mandatory when uploading products in interactions.

ItemTypeXProduct type, for example SAP_CRM_PRODUCT, SAP_HYBRIS_PRODUCT, SAP_ERP_MATNR

Please read through following too:

https://uacp2.hana.ondemand.com/viewer/c43005898be34c8ca6c433635fbb18ca/1708%20500/en-US/60ff8b5544fdbf5de10000000a423f68.html

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Akil,

Thanks for your answer.

Now I have included ItemType with request and also referred the help link to structure with mandatory fields but got same response.

Sample Request:

{

"ID" : "10004",

"SourceSystemId" : "ANY",

"SourceSystemType": "",

"Timestamp" : "/Date(20170801222212)/",

"UserName": "XYZ",

"Interactions" : [

{ "Key" : "",

"CommunicationMedium" : "BUSINESS_DOCUMENT",

"ContactId" : XYZ@gmail.com",

"ContactIdOrigin" : "EMAIL",

"InteractionType" : "SALES_ORDER",

"IsAnonymous" : "false",

"Timestamp" : "/Date(20170801222212)/",

"Products" : [

{ "ItemId" : "YYYYY0700S",

"ItemType" : "SAP_C4C_PRODUCT",

"Quantity": "2",

"Amount": "100", } ] } ] }

Thanks and regards,

Dinesh.

0

Hi Dinesh,

JSON Syntax was having wrong format at AMOUNT field. Please find the corrected JSON:

{
"ID": "10004",
"SourceSystemId": "ANY",
"SourceSystemType": "",
"Timestamp": "/Date(20170801222212)/",
"UserName": "XYZ",
"Interactions": [{
"Key": "",
"CommunicationMedium": "BUSINESS_DOCUMENT",
"ContactId": "XYZ @gmail.com ",

"ContactIdOrigin": "EMAIL",

"InteractionType": "SALES_ORDER",

"IsAnonymous": "false",

"Timestamp": "/Date(20170801222212)/",

"Products": [

{
"ItemId": "YYYYY0700S",

"ItemType": "SAP_C4C_PRODUCT"
}
]
}]
}

0
Vineet Kaul Sep 08, 2017 at 12:24 PM
0

Hi Dinesh,

It should accept Amount as well as long as its in the required format and is passed in between "23.50".

Also i see that its the last value in your product segment can you remove the closing comma at the end of the amount.

I believe the comma makes the system believe that another value is following while the data is being closed.

I am not an expert on ODATA but i did check it in my system and Amount is working and last value should not be followed by comma.

Thanks

Vineet.

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Vineet,

Thanks for the response.

I was able to post sales order successfully by modifying structure after validating JSON format.

Thanks and regards,

Dinesh.

0