python - Hubspot API 未填充交易
问题描述
当我尝试通过 hubspot api 创建交易时,即使我正在通过填充的数据,所创建的只是一个完全空白的交易
API 网址:https ://developers.hubspot.com/docs/api/crm/deals
这是我正在尝试的以下代码:
import json
import requests
hubspot_api_key = "MY_API_KEY"
url = 'https://api.hubapi.com/crm/v3/objects/deals?hapikey={}'.format(hubspot_api_key)
headers = {"Content-Type": "application/json"}
deals_post = {
'amount': "4034.75",
'closedate': '2021-05-10T12:04:00.000Z',
'dealname': 'Custom data integrations',
'dealstage': 'closedwon',
'hubspot_owner_id': "5448459615",
'pipeline': 'default'
}
response = requests.post(url, headers=headers, data=json.dumps(deals_post))
print(response.text)
这是它的结果:
解决方案
此问题的解决方案是将属性添加到数据字典
import json
import requests
hubspot_api_key = "MY_API_KEY"
url = 'https://api.hubapi.com/crm/v3/objects/deals?hapikey={}'.format(hubspot_api_key)
headers = {"Content-Type": "application/json"}
deals_post = {
'properties': {
'amount': "4034.75",
'closedate': '2021-05-10T12:04:00.000Z',
'dealname': 'Custom data integrations',
'dealstage': 'closedwon',
'hubspot_owner_id': 83849850,
'pipeline': 'default'
}
}
response = requests.post(url, headers=headers, data=json.dumps(deals_post))
print(response.text)
这会根据传入的数据生成一个已填写的交易
推荐阅读
- php - 使用php通过CSV导入mysql表中的数据
- sap - 如何在 SAP HANA SP12 中实现物化视图
- opendaylight - OpenDaylight Oxygen: No DLUX app?
- c# - 简化文本框中的 if 语句?
- weka - 我无法在 weka 中为我的 id3 分类器可视化决策树。我应该怎么办?
- sql - 每次更新都不会触发触发器
- reactjs - 将第三方 javascript 库导入 react
- javascript - 滚动事件的问题
- laravel - Laravel 5.4 中的电子邮件或电话验证
- java - 专辑封面没有出现在我的 RecyclerView 中