502 Bad Gateway when querying from NetSuite

I’m trying to make graphql queries from NetSuite SuiteScript and no matter what I do, I’m getting a 502 Bad Gateway error. Below is the simplest version of the script making the call. The only thing I seem to be able to do with any change is to modify the authorization header which results in a 401 Unauthorized response. Otherwise, I get the following response:

Bad Gateway response

{
  "type": "http.ClientResponse",
  "code": 502,
  "headers": {
    "Content-Length": "21",
    "content-length": "21",
    "Content-Type": "text/html; charset=UTF-8",
    "content-type": "text/html; charset=UTF-8"
  },
  "body": "Bad Gateway: /graphql"
}

NetSuite Script

function shQuery() {
	const endPoint = "https://public-api.shiphero.com/graphql";
	var headers = {
		ContentType: "application/json",
		Authorization:"Bearer TOKEN"
	};

	var response = https.post({
		url: endPoint,
		body: JSON.stringify({query: "{__schema{types{name}}}"}),
		headers: headers
	});

	return response;
}

Any help in understanding what I’m doing wrong would be greatly appreciated.

Hi @jaye.c ,

If you cut it down to the exact call that is failing and send us the request_id, we could troubleshoot it on the basic level.

Best,
Theresa

Hi @Theresa, Thanks for the help.

Below is the basest level of the call I can provide. The https.post function is the NetSuite API function which triggers the server to make the call. I don’t have direct access to the server though.

As the only information I get back is the 502 error I don’t receive a request_id. Is the request_id something I should be generating? It was my understanding that that was a field which gets returned with the data.

I’m not sure this will help but the one method I’ve found that returns anything different is by invalidating the authorization token (by changing a character in it). When I do that, instead of the 502 get a 401 Unauthorized error code.

Thanks,
Jaye

Hello @jaye.c!

Can you share with my Account ID (customer) and User ID (or the email with which it was registered) of the user account that is set up for making the calls?

Have a great day!
TomasFD

Certainly.

Account ID: QWNjb3VudDo2MjAwNA==
User ID: it@greengoohelps.com

I wasn’t sure where to find the account ID in the admin so I used Altair (which works fine for API calls) using the following query to get it:

account {
  request_id
  complexity
  data {
    id
  }
}
1 Like