sampippin
sampippin

Reputation: 133

Accessing Netsuite Saved Search Data From Python

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?

Upvotes: 0

Views: 1805

Answers (1)

Ioannis Tsakatanis
Ioannis Tsakatanis

Reputation: 1

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)```

Upvotes: 0

Related Questions