1

Here's a brief description of what I'm trying to do:

  • get a field's value
  • multiply that value by a constant
  • update the field with the adjusted value

I am using a nice wrapper found here: https://github.com/hiway/pipedrive-api

Here is my code:

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

So expected output would be:

>>>Previous value was  5.0
>>>New Value is  4.8
>>>4.8

However, I'm getting:

>>>Previous value was  5.0
>>>New Value is  4.8
>>>5

Any ideas would be greatly appreciated!

  • What HTTP status code and content was returned from the `PUT` operation? – Nathan Baulch Sep 23 '15 at 13:21
  • When I turn on debugging, I get: `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: *` ... – RobotLauren Sep 23 '15 at 17:59
  • Pretty sure the problem is with my Json command in lines 11-13, but I'm honestly new to interacting with APIs anyway and I'm not sure I understand the PUT command or JSON well enough? – RobotLauren Sep 23 '15 at 18:06

2 Answers2

0

your put is probably failing. put quotes around id:

pd.deals.put({ 'id':693, 'value': New_value})

0

Of course it was a syntax issue, found after extensive debugging. The new code now appears like this:

pd.deals.put(
    id=693,
    data={
    "value":New_value})

Where the change is reflected by moving the deal id outside of the data field.