0

I am trying to access the data obtained from Netsuite Saved Search using python. I want to write a script (in python) that runs a saved search and saves the results on my computer.

Where can I read about how to structure my API requests to successfully do this? The help documentation is horrible.

Any code examples to do this in python?

sampippin
  • 123
  • 1
  • 2
  • 12

1 Answers1

0

Assuming that: 1) you have already created an integration in NetSuite and you have the tokens ready 2) you have already deployed a suitescript that runs a saved search

Then your python script can be the following:

from requests_oauthlib import OAuth1Session

session = OAuth1Session(
    client_key='**YOUR_KEYS**',
    client_secret='**YOUR_KEYS**',
    resource_owner_key='**YOUR_KEYS**',
    resource_owner_secret='**YOUR_KEYS**',
    signature_type='auth_header',
    signature_method='HMAC-SHA256',
    realm='**YOUR_NETSUITE_ACCOUNT_NUMBER**',
)

r = session.get(

 url='https://**YOUR_NETSUITE_ACCOUNT**.restlets.api.netsuite.com/app/site/hosting/restlet.nl?script=**YOUR_SCRIPT_DEPLOYMENT_ID**&deploy=1&searchId'
                '=**YOUR_SAVED_SEARCH_ID**',
            headers={'Content-Type': 'application/json'
                     }
        )

netsuite = r.json()
print(netsuite)```
  • Thank you for providing a SHA256 example. Official documentation doesn't have such example and they threaten making SHA1 unusable. – Kyle Waid Jun 22 '21 at 23:47