cancel
Showing results for 
Search instead for 
Did you mean: 

Settings a HTTP response code for triggered tasks

Henchway
Contributor

Hi everyone,

we’re offering a triggered task as a sort of simplified API for a more complex REST API (specifically Jira).

What we want to achieve is to influence the HTTP return code, status and message we deliver back to the caller of the triggered task based on the return result of the REST API.

Here’s a brief description for context:

image

Assuming there’s an error in the Jira Search snap, the error will bubble up to the pipeline execute snap, which in turn triggers the attached error pipe of the template pipe.
This will ensure that the error is correctly logged, however, the response to the caller of the triggered task will be 200 in any case.

I’m unsure of 2 points:
Where is the response formed and delivered back to the caller? At the Error pipe or already somewhere before that?
Is there any way to influence what is delivered back to the caller? Ideally we’d like to implement a solution in the template pipeline for e.g. common response codes, but want to refrain from having to implement ‘repsonse code conditionals’ in every integration pipeline.

Any suggestions are highly appreciated!

Thanks and best regards
Thomas

7 REPLIES 7

If you use the document to binary snap method as mentioned above, the $content field in the document being transformed to binary becomes the response body, and the rest of the fields are treated as response headers.

SpiroTaleski
Valued Contributor

@scotth

Another approach is by using the Mapper Snap with Binary output. Find the attached sample pipeline:

CustomResponsePipe_2021_12_24.slp (3.8 KB)

Regards,
Spiro Taleski

scotth
New Contributor II

@Spiro_Taleski
@cjhoward18
Both great solutions, thanks.