How to pass HTTP codes in JSON output

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”
}

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

1 Like

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.

@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.

2 Likes

Thanks @j.angelevski