Forum Discussion
In a Mapper snap you can set the Mapping Root to the array, which can sometimes make writing expressions easier. Take a look at this example and let me know if it helps.
Wow, I never used the pass through with mapping root. I was able to get it to work.
Thank you!
Bill
Could you include some more information regarding your implementation and what you’re trying to do? If I understand your question you are trying to check if there were failed insertions. If so, then the task should respond with an error message and a non-200 status code. If that’s correct then you might look at this kind of pipeline.
You can use the JSON Generator to set the failed count, which will determine if there is an error. Here are some additional notes for the 4 key snaps required to get this done.
- This Router will check for failures and if surpasses the error threshold, routes the document to the bottom output view.
- The
Set Error
mapper snap will set an error message and status code that the task should return in the HTTP response. - The exit snap will surpass the threshold and is used to put the pipeline in a failed state.
- The JSON formatter can be used to set the status code on the HTTP response. This is done by setting a special field called
status
in the binary document header.
When executed as a triggered task, then you should see this kind of response. I removed some headers from the response to make it easier to read.
< HTTP/1.1 500 INTERNAL SERVER ERROR < Date: Wed, 02 Nov 2022 20:33:46 GMT < Content-Type: application/json; charset=utf-8 < X-SL-StatusCode: 500 < X-Snapi-pipeline-ruuid: XXXX08ba ... < [{"status":500,"error":"oh no!"}]
In the dashboard it’ll show up like this.
Here is an attached pipeline if you’d like to try it out.
exit-example_2022_11_02.slp (9.9 KB)
Related Content
- 3 months ago