Hello, I've successfully signed and sent a GET request via python using the oauthlib.oauth1 library. An example is pasted below for anyone else trying to get past this hurdle.
However, when I try to do a POST request to query data, I am hit with an Invalid login attempt. I assume something is going wrong with my signature but not sure where it is going wrong. Any experts out there have a successful Token-Based Authorization POST request (to Query data or otherwise?). I've verified that I can run this query in Postman and the credentials do work for the GET request so I know my credentials are entered correctly.
Successful GET request connection:
import oauthlib.oauth1
import requests
url = 'https://[account].suitetalk.api.netsuite.com/services/rest/record/v1/invoice/[invoice_number]'
request_type = "GET"
client = oauthlib.oauth1.Client('client_id',
client_secret='client_secret',
resource_owner_key='access_token',
resource_owner_secret='access_token_secret',
realm='realm',
signature_method='HMAC-SHA256')
url, headers, body = client.sign(url)
response = requests.request(request_type, url, headers=headers, data=payload)
Non Successful POST request
import oauthlib.oauth1
import requests
url = 'https://[account].suitetalk.api.netsuite.com/services/rest/query/v1/suiteql?limit=100'
request_type = "POST"
data = {"q": "SELECT * FROM transaction"}
client = oauthlib.oauth1.Client('client_id',
client_secret='client_secret',
resource_owner_key='access_token',
resource_owner_secret='access_token_secret',
realm='realm',
signature_method='HMAC-SHA256')
url, headers, body = client.sign(url, headers={'Content-Type': 'application/json'})
response = requests.request(request_type, url, headers=headers, data=payload)
Response: :[{"detail":"Invalid login attempt. For more details, see the Login Audit Trail in the NetSuite UI at Setup > Users/Roles > User Management > View Login Audit Trail.","o:errorCode":"INVALID_LOGIN"}
Login Audit shows InvalidSignature error.
Thank you!