【发布时间】:2015-09-23 07:47:30
【问题描述】:
以下是我正在尝试做的简要说明:
- 获取字段的值
- 将该值乘以一个常数
- 使用调整后的值更新字段
我正在使用在这里找到的一个不错的包装器:https://github.com/hiway/pipedrive-api
这是我的代码:
from pipedrive import Pipedrive
pd = Pipedrive('API_token')
# ^ insert API token
EAAR = pd.deals.get(id=693) ## parse info from given deal/field
Current_value = float(EAAR.value) ## convert value to decimal
print 'Previous value was ', Current_value
New_value = Current_value * 0.96
print 'New Value is ', New_value
pd.deals.put({
id:693,
'value': New_value})
EAAR2 = pd.deals.get(id=693)
print EAAR2.value
所以预期的输出是:
>>>Previous value was 5.0
>>>New Value is 4.8
>>>4.8
但是,我得到:
>>>Previous value was 5.0
>>>New Value is 4.8
>>>5
任何想法将不胜感激!
【问题讨论】:
-
PUT操作返回了什么 HTTP 状态代码和内容? -
当我打开调试时,我得到:
send: 'GET /v1/deals/693?api_token=[API_token] HTTP/1.1\r\nHost: api.Pipedrive.com\r\nConnection: keep-alive\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nUser-Agent: python-requests/2.7.0 CPython/2.7.3 Windows/7\r\n\r\n' reply: 'HTTP/1.1 200 OK\r\n' header: Server: nginx header: Date: Wed, 23 Sep 2015 17:58:37 GMT header: Content-Type: application/json header: Transfer-Encoding: chunked header: Connection: keep-alive header: X-Frame-Options: SAMEORIGIN header: X-XSS-Protection: 1; mode=block header: Access-Control-Allow-Origin: *... -
很确定问题出在我的第 11-13 行中的 Json 命令上,但老实说,我对与 API 交互还是很陌生,我不确定我是否足够了解 PUT 命令或 JSON?
标签: python pipedrive-api