RE: Why does my SuiteQL POST request work when I use Postman, but when I cURL the same code in VS Code terminal, it returns ‘INVALID_LOGIN’

I’m trying to use SuiteQL to query a workbook, but I’m having trouble getting it to work in VS Code. I downloaded the Postman environment template and collections archive from the SuiteTalk tools download page and then sent a test request. It returned a successful JSON response. I then tried to send the same sample request using cURL in the VS Code terminal, then with node-fetch, and then using an npm library called netsuite-rest. All of these return 401 ‘INVALID_LOGIN’. Why does it work when I use Postman, but nowhere else? Here’s a sample of my cURL request:

curl --location --request POST 'https://<ACCOUNT_ID>.suitetalk.api.netsuite.com/services/rest/query/v1/suiteql?limit=5' \
--header 'prefer: transient' \
--header 'Content-Type: application/json' \
--header 'Authorization: OAuth realm="<ACCOUNT_ID>",oauth_consumer_key="<CONSUMER_KEY>",oauth_token="<TOKEN>",oauth_signature_method="HMAC-SHA256",oauth_timestamp="<TIMESTAMP>",oauth_nonce="<NONCE>",oauth_version="1.0",oauth_signature="<SIGNATURE>"' \
--header 'Cookie: NS_ROUTING_VERSION=LAGGING' \
--data-raw '{
    "q": "SELECT id, companyName, email, dateCreated FROM customer WHERE dateCreated >= '\''01/01/2019'\'' AND dateCreated < '\''01/01/2020'\''"
}'

RomanEmmons Rookie Asked on August 18, 2020 in SuiteTalk.
Add Comment
2 Answers

Hi,

There are plenty of places to go wrong with this unfortunately. I’d recommend having a look at these:
https://netsuite.custhelp.com/app/answers/detail/a_id/77576/kw/tba%20signature/related/1
https://netsuite.custhelp.com/app/answers/detail/a_id/42019

And then check specifically:
* Alphabetical sorting of parameters.
* URL encoding.

Thanks,

Chris

Intermediate Answered on August 19, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.