I'm trying to send the below payload (JSON) to a REST endpoint, but when I use conventional mapping in BizTalk to build the XML schema, and then use the JSON encoder in a custom pipeline to send it out, it doesn't include the required array in filters (its a REST call requirement that the filters record is arrayed, even if there's only 1 filter record within)
{
"busObId": "9343f8800bd7ce14f0bf0a402d9d38be1a25069644",
"filters": [
{
"fieldId": "937905400191ae67dd03ab4b79968fcbaa264b1a75",
"operator": "eq",
"value": "TIER1WEB02"
}
],
"includeAllFields": false,
"includeSchema": false
}
I've considered using message assignment to manually write an XML structure, but I can't figure out how to get the JSON encoder to array the filters element.
Can anyone please advise on how I can ensure that payload is not removing the []
around filters?
Make sure that your pipeline has a XML Assembler in the pipeline before the JSON Encoder.
QUIRK: THE BIZTALK JSON ENCODER – JSON ARRAY
Details: JSON Encoder not creating JSON Array for what should be a repeating element. This occurs if you don’t have schema deployed that matches the XML payload and there is only a single item. See JSON Array – BizTalk JSON Encoder
Work Around: The XML must conform to a schema that BizTalk knows about. Use a custom send pipeline that contains a XML Assembler pipeline component before the JSON encoder pipeline component.
From my blog BizTalk 2013 R2 known bugs, issues & quirks