AnsweredAssumed Answered

How can I handle an empty JSON array in an HTTP response?

Question asked by cegbert328645 on May 5, 2017
Latest reply on May 5, 2017 by cegbert328645

I have a process that is expecting a JSON response in the form of an array of JSON objects. When data is returned, the process completes successfully. But, when no data is returned, I get a response with an empty array like so:

 

[]

 

This fails when it reaches the map because the map is expecting the array to have data in it. This is even though I set "Min Occurs" to "0". I even tried "Min Occurs" to "1" just to see if I get something different, but I got the same result. I expected Boomi to treat it as an empty document and complete the process. I do not have a try/catch shape to work with in this scenario. How do I handle the empty response? Thank you for your help. All the details are below:

 

 

Here is the basic process in the canvas:

Process Canvas

 

 

Here is the HTTP POST Operation:

HTTP Operation

 

 

Here is the JSON profile generated from the import wizard from real data along with the root details:

JSON Response Profile

 

 

Array details in JSON response profile:

Array Details

 

 

ArrayElement details in JSON response profile:

ArrayElement Details

 

 

Here is what the JSON looks like when there are records returned:

Response Data when Data is returned.

 

 

Here is the error message when an empty array is returned:

Error when no data is returned.

 

 

It fails on the map shape:

Process fails on map.

 

 

Here is what the JSON response looks like when there are no records returned:

Response JSON when no data is returned.

 

Again, thank you for the guidance.

 

json profile

Outcomes