“Accept” encoding types recognized by Netsuite


I am making a restlet call to Cybersource to retrieve transaction records.  The get request needs an “Accept” header.
var headers = new Array();
headers[“Accept”] = “application/hal+json;charset=utf-8″;

When I do the call var the response = nlapiRequestURL(url,”, headers,’GET’);  the response is a 406 error. Indicated Netsuite does not recognize the response type. A get request that needs an Accept Header of application/json works fine in another script. the call also works fine outside the Netsuite environment.
Does anyone know if Netsuite recognizes the hal+json  Accept type?
I am using Suitescript 1.0.


Rookie Asked on June 16, 2020 in SuiteScript.
Add Comment
3 Answer(s)
Best answer

I believe your understanding of that header is reversed.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406: 406 Not Acceptable client error response code indicates that the server cannot produce a response matching the list of acceptable values defined in the request's proactive content negotiation headerse.

In your context, NetSuite is the client and Cybersource is the server. Cybersource cant generate application/hal+json in utf-8 so it returns the 406 error code.

Intermediate Answered on June 16, 2020.

You might want to try SuiteScript 2. The following works fine

require(["N/https"], function (https) {
   headers: {
    Accept: "application/hal+json;charset=utf-8",
    "v-c-merchant-id": "testrest",
    "v-c-date": "Tue, 16 Jun 2020 17:10:06 GMT",
     'keyid="08c94330-f618-42a3-b09d-e1e43be5efda", algorithm="HmacSHA256", headers="host (request-target) v-c-merchant-id", signature="DhdbMJ0BcdVoOsX6A0218/ONhVHiCdsXSJofYhqwjyM="',

on June 16, 2020.
Add Comment

Problem is, using Node.js and the accept header of hal+json  I get a 200 response and the hal-json response object. Cyberspurce is saying it’s an issue with Netsuite.

Rookie Answered on June 16, 2020.
Add Comment

Using SuiteScript 2.0 was the answer the Accept type application/hal+json does not exist in 1.0.

Rookie Answered on July 14, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor