HTTP Response Code (Header) for Triggered Task

I have a triggered SnapLogic REST API task, with a pipeline that calls a separate vendor REST API. I want to catch any errors from the vendor API so I can return them back in my SnapLogic API response. If I do though, then the error is considered handled and the HTTP response code back to my requester indicates success. If I don’t handle the error, then the pipeline will fail and provide back a generic failure HTTP response code, but without any of the details from the vendor response.

Is it possible to catch/handle the vendor API error, with a successful pipeline execution, but somehow manipulate the SnapLogic HTTP response code with an error code?

At this time HTTP response codes cannot be manipulated using Triggered Tasks.

Only ULTRA tasks can be programmed to return different HTTP response codes.

https://www.snaplogic.com/blog/ultra_pipelines_error_handling

Oh okay… :frowning: Thanks for the information.

I think the post
https://www.snaplogic.com/blog/ultra_pipelines_error_handling

just showing how we can manipulate the response body with different error code.(though the response Header is still with code 200)

But, as the questions asked, and same here, how can we change the response Header status code?

Thanks

Do you have an Ultra Environment to verify?

Here is a screenshot from my ultra test response in postman. It is certainly possible to put a different status codes in the header response.

Hi

Thanks for your information, but can you show me the code in your mapper on how you add that custom_header1?

Thanks

As long as the $content is mapped, everything else you pass in the mapper goes to the header.

This is the only thing I have in the pipeline.

You should read the Ultra Documentation again specifically concentrating on these points.

https://docs-snaplogic.atlassian.net/wiki/spaces/SD/pages/1437955/Ultra+Pipeline+Tasks

The unlinked output view type can be binary or document as well:
If it’s document, the output should have a ‘content’ field that will be JSON-encoded and sent back to the client. The other fields in the output document will be treated as HTTP response headers to send back to the client. If there is no ‘content’ field, the entire document will be JSON-encoded and used as the response body to be sent back to the client.
If the output document contains a ‘status’ field that is an integer, it will be treated as the HTTP response status code.

If it’s binary, the binary document’s header will be sent back to the client as the HTTP response headers. The body of the binary document will be directly streamed back to the client.
SnapLogic expects exactly one output document for every input. If no output is sent, then the original HTTP request sent to the FeedMaster will hang and eventually timeout. If more than one output document is generated, then SnapLogic will only send the first one back as the response to the original HTTP request. This behavior is different from a Triggered Task, where all of the documents sent to the unlinked output are sent back in the response.

This is really helpful. Thanks a lot