I get 200 using POSTMAN while 406 using nlapiReque...
# suitescript
t
I get 200 using POSTMAN while 406 using nlapiRequestURL()
var settings = {
  
"url": some URL here,
  
"method": "POST",
  
"timeout": 0,
  
"headers": {
    
"Content-Type": "application/json",
    
"Cookie": "__cfduid=d3e371568b80d7f3fc091f568eed250481591877837"
  
},
  
"data": JSON.stringify({"shopifyDomain":"DOMAIN here","operation":"ITEM","authenticationKey":"key here","dataList":[{"variants":[{"sku":"DA-06-Black","inventory_policy":"deny","barcode":"711005824002","weight":"1.9","weight_unit":"lb","inventory_management":"shopify","tracked":true}]}]}),
};
$.ajax(settings).done(function (response) {
  
console.log(response);
});
Above is the postman request code
Below is NS code
var url = "Some URL here";
var headers = {
"Content-Type": "application/json"
};
var metaFieldArr = {
"shopifyDomain": "Domain here",
"operation": "ITEM",
"authenticationKey": "key here",
"dataList": [
{
"variants": [
{
"sku": "DA-06-Black",
"inventory_policy": "deny",
"barcode": "711005824002",
"weight": "1.9",
"weight_unit": "lb",
"inventory_management": "shopify",
"tracked": true
}
]
}
]};
var response = nlapiRequestURL(url, JSON.stringify(metaFieldArr), headers, "POST");
nlapiLogExecution("debug","response ",response.getBody());
b
try adding the Accept header set to *`*/*`*
or perhaps
Copy code
Accept: application/json
t
Ohh thanks, it worked.
@battk why does it take "Accept" instead of content type ?
b
in this context, Content-Type refers to the content in the request body
Accept is what your client expects from the response
t
but why does it work with postman then ?
Doesn't client expect the same using that ?
b
perhaps postman is actually sending the header anyways
t
message has been deleted
b
that looks like a response header
i personally like the postman console for this kind of thing
t
sorry ,yes that is response header
message has been deleted
here is the request header
and that does contain accept
Thanks, I always get to learn things from you.
You should be in the meme "Not all heroes wear capes " 😄
Sorry, no offence 😄