1.2k questions
1.4k answers
361 comments
339 users
In order to set the content-type of the http response, you will need to prepend your message content with actual http header for Content-Type. So, you will want to set the content type something like this:
var contentType = "application/json"; var contentTypeLine = "http.header.Content-Type=" + contentType + "\r\n\r\n"; qie.postMessageResponse(contentTypeLine + message.getNode('/'));
Note: The prefix "http.header." before the header name (in this case Content-Type) followed by "=" and the header value, and a carriage return line feed (\r\n) are required.
See also:
Handling HTTP requests and responses
Posting Responses via qie.postMessageResponse() in a channel that uses an HTTP Listener source node
Another example to add an http header to a message response is the following
qie.postMessageResponse('http.header.Access-Control-Allow-Origin=*\r\n' + message);
Here is an example of returning multiple headers. They all should start with "http.header." and end with "\r\n" Example: qie.postMessageResponse('http.header.Access-Control-Allow-Origin= *\r\nhttp.header.Transfer-Encoding=chunked\r\n' + message);