python - 从 Python 访问 Netsuite 保存的搜索数据
问题描述
我正在尝试使用 python 访问从 Netsuite Saved Search 获得的数据。我想编写一个脚本(在 python 中)运行保存的搜索并将结果保存在我的计算机上。
我在哪里可以阅读有关如何构建我的 API 请求以成功执行此操作的信息?帮助文档很糟糕。
在 python 中执行此操作的任何代码示例?
解决方案
假设:1)您已经在 NetSuite 中创建了一个集成并且您已经准备好令牌 2)您已经部署了一个运行已保存搜索的套件脚本
那么你的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)```
推荐阅读
- python - 跳入我的 pygame 程序不起作用 - 跳到屏幕顶部并进入平台下方
- java - 如何编写 Drake 排序算法以在 Java 中对数组进行排序?
- c++ - CMakeLists.txt。从程序输出设置宏
- toit - 如何轻松地在 toit 控制台上发出和显示指标
- java - 在Java中实现工厂方法
- python - 如何在 Python 中运行具有固定效果的 diff-in-diff?
- jmeter - 使用 JSR223 PostProcessor 从未排序的数组列表中获取最大值
- amazon-web-services - 我可以将列表用作 AWS 资源标签的值吗?
- python - CPLEX python 中的动态工作者约束
- java - 使 JButton 在尝试连接到套接字时向 JTextArea 打印“正在连接..”消息