简体   繁体   English

从 Python 访问 Netsuite 保存的搜索数据

[英]Accessing Netsuite Saved Search Data From Python

I am trying to access the data obtained from Netsuite Saved Search using python.我正在尝试使用 python 访问从 Netsuite Saved Search 获得的数据。 I want to write a script (in python) that runs a saved search and saves the results on my computer.我想编写一个脚本(在 python 中)运行保存的搜索并将结果保存在我的计算机上。

Where can I read about how to structure my API requests to successfully do this?我在哪里可以阅读有关如何构建 API 请求以成功执行此操作的信息? The help documentation is horrible.帮助文档很糟糕。

Any code examples to do this in python?在 python 中执行此操作的任何代码示例?

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假设:1) 您已经在 NetSuite 中创建了一个集成并且准备好了令牌 2) 您已经部署了一个运行保存搜索的套件脚本

Then your python script can be the following:那么你的python脚本可以是以下内容:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM