Skip to Content
0

Inserting data into Hybris using OData interface - Error while parsing an XML stream

Aug 31, 2017 at 07:15 PM

99

avatar image
Former Member

We have some issues when utilizing the “Product” entity within Hybris.

Getting an error that says ‘Error while parsing an XML stream’ when trying to import data into Hybris using the OData interface.

Here’s a link to what the request looks like that I’m sending to Hybris: https://gist.github.com/mniehe/c25f4130b811889ec0b9f9df18e57159

If I take that same request but delete the “Products.Quantity” and “Products.Amount”, it works without any problems. So it must be with how I’m sending those two fields. I checked the interface guide for our version of Hybris, and it says those two fields should exist on “InteractionProduct”. Am I misreading how those fields should be used? Or maybe that “Products” array isn’t mapping properly to “InteractionProduct”? Any guidance would be helpful since ‘Error while parsing an XML stream’ is a completely useless error message.

Hoping you can assist or point us in the right direction.

10 |10000 characters needed characters left characters exceeded

Hi Andrew,

Sample payload for sending the SALES_ORDER with products is as follow:

{
	"Id": "",
	"Timestamp": "2016-01-14T16:57:43.1190000",
	"UserName": "",
	"SourceSystemType": "",
	"SourceSystemId": "SAP_MERCH_SHOP",
	"Interactions": [{
		"ContactIdOrigin": "SAP_HYBRIS_MKT_IC",
		"ContactId": "02000A1BA8A81ED781ADBE13368CCA99",
		"CommunicationMedium": "BUSINESS_DOCUMENT",
		"InteractionType": "SALES_ORDER",
		"SourceObjectId": "SAP_HYBRIS_COMMERCE",
		"Timestamp": "2017-05-14T16:57:44.1190000",
		"Valuation": 5,
		"Amount": "300.30",
		"Currency": "EUR",
		"Products": [{
				"ItemType": "SAP_HYBRIS_PRODUCT",
				"ItemId": "PH001",
				"Amount": "200",
				"Quantifier": 1,
				"Quantity": "1",
				"UnitOfMeasure": "EA"
			},
			{
				"ItemType": "SAP_C4C_PRODUCT",
				"ItemId": "P300403",
				"Amount": "100.30",
				"Quantifier": 1,
				"Quantity": "1",
				"UnitOfMeasure": "EA"
			}
		]
	}]
}



Thanks

Saurabh

0
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Johannes Voglsam
Sep 02, 2017 at 03:13 PM
0

Hello Andrew,

please try with putting the amount value in double quotes:

"Amount" : "13394.8"

The amount is sent as JSON string - according to OData json format documentation http://www.odata.org/documentation/odata-version-2-0/json-format/ the double value must use quotes (") because double are formatted as a JSON string.

best regards,

Johannes

Share
10 |10000 characters needed characters left characters exceeded