https.getRequestHeaders
# ask-stanley-ai
t
https.getRequestHeaders
c
AI generated answer (using internal Slack threads):
In SuiteScript 1.0, the
request.getAllHeaders()
method is used to retrieve all the headers from a request. However, it seems to return a
string[]
with all the header keys, but no header values. This behavior is also indicated in this [post](https://www.netsuiterp.com/2018/09/using-nlobjresponse-getallheaders-and.html). To get the header values, you can iterate over the list and use
request.getHeader(headers[i])
to build your map. Here's an example:
Copy code
javascript
var allHeaders = request.getAllHeaders(), headersObj = {};

for (var header in allHeaders) {
    headersObj[header] = allHeaders[header];
}
response.setContentType('JSON');
response.write(JSON.stringify(headersObj));
In SuiteScript 2.0, you can use
context.request.headers
to get the headers from a request. In the context of a Restlet, it seems that only the body is passed in the context object. If you need to read request headers, you might need to include them in the body of the request or find another workaround. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.820068359
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.817260802
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.814575195
Please provide your feedback on this answer.