cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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.

former_member226
Employee
Employee
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member196553
Active Contributor
0 Kudos

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