Really quick question... first time using the N/ht...
# suitescript
s
Really quick question... first time using the N/https module and I need to send multiple headers in my request. wondering if this is legal, as ALL the examples in NetSuite Help show one header only.... my code
b
your example sucks, use headers as an Object, not an array
s
an object of objects?
p
Copy code
var headers = {
    'accept-language': 'en-CA',
    'accept': 'application/vnd.cpc.track-v2+xml',
    'authentication': 'Basic' + encoded_auth
};
b
p
@battk isn't this example from ns wrong too? lol
s
Thats what I was wondering
b
oh you are right, didnt even read the keys
p
@Seth_at_TBMBM try what i sent, i'm mostly certain it's just a simple key/val object (aka: hashmap)
and the doc is wrong
s
I did try, and it's working now. Thanks very much
👍🏽 1
s
I built my heads for a rest API this way and it works as well
var objHeaders = {};
objHeaders["Content-Type"] = "application/json";
objHeaders.accept = "application/json";
objHeaders.Authorization = "Basic " + Authstring;