cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass HTTP codes in JSON output

kumar25
New Contributor II

Hi,

I have a JSON like below, have to pass the value of StatusCode into HTTP Header. I am using JSON Formatter, but incase of Failure also it gives 200 with the actual code in the JSON payload. Help me in how to handle this

JSON:
{
“StatusCode”:“500”,
“StatusMessage”:“Success”
}

4 REPLIES 4

j_angelevski
Contributor III

Hi @kumar25,

You can add the headers you want in the Binary header properties in the JSON Formatter snap.
In your case instead of using ‘500’ in the expression field like in the sample below, you can use $StatusCode.
image

kumar25
New Contributor II

Hi @j.angelevski ,

I am able to get the error code in HTTP header along with that the entire message is published in the payload(as i am passing the entire input in the content of JSON Formatter).

How can i exclude statuscode field to be populated in the response.
image

@kumar25

You can choose what to provide in the response by changing the Content property by selecting the
StatusMessage field from the input or you can have a Mapper snap before the JSON Formatter and map the values that you only need.

kumar25
New Contributor II

Thanks @j.angelevski