Responding to requests with HTTP status codes

0 votes
asked Mar 20, 2018 by (240 points)
It seems like every request made to QIE gets a response back with an HTTP status code of 200 or 500.  Is there a way to manually set the HTTP status code on responses.  For instance, if I wanted to return 400 series codes for request/auth issues.  Or if I wanted to just manually return a 500 without relying on the underlying QIE code failing.

1 Answer

+1 vote
Best answer

You can add the following options to the start of the response:

var response = "HTTP Status: 404\r\n";
response += "Content-Type: text/plain\r\n";
response += "httpHeader: myToken:ABCDEF\r\n";
response += "This is my payload";


The HTTP status can return any integer value for the status code.

The Content-Type allows you to specify the payload content type.

The httpHeader can be any additional headers that are needed in the response.  To specify a header, you will separate the header name (key) and the value with a colon (:).


Make sure that you have set your source node to response to "From Mapping or Destination node"


You can create a custom mapping function withe the qie.postMessageResponse(response);

answered Mar 20, 2018 by ben-s-7515 (11,910 points)
selected Mar 20, 2018 by
commented Nov 17, 2021 by golden-m-1060 (120 points)
I'm using this to check an api token in the first step of my mapping function.  If the api-token isn't valid I'm posting the message response as shown above, but how can I stop processing at that point?  If I use a return statement, (at least in test mode) the rest of the mapping function executes.