al3xicon
01/05/2017, 3:20 PMimport requests
import oauth2 as oauth
import time
import os
search_id = 188046
rest_url = '<https://rest.netsuite.com/app/site/hosting/restlet.nl?script=377&deploy=1&search_id=>'+str(search_id)+'&start=0&end=1000'
token = oauth.Token(key='KEY',
secret='SECRET')
consumer = oauth.Consumer( key='KEY',
secret='SECRET')
params = {
'oauth_version': '1.0',
'oauth_nonce': oauth.generate_nonce(),
'oauth_timestamp': str(int(time.time())),
'oauth_token': token.key,
'oauth_consumer_key': consumer.key
}
req = oauth.Request(method="GET", url=rest_url, parameters=params)
signature_method = oauth.SignatureMethod_HMAC_SHA1()
req.sign_request(signature_method, consumer, token)
header = req.to_header('ACCTID')
headery = header['Authorization'].encode('utf-8', 'ignore')
headerx = {"Authorization": headery, "Content-Type": "application/json"}
try:
conn = requests.get(rest_url, headers=headerx)
except requests.exceptions.RequestException as e:
print(e)