i asked question involving put request , solution update url https://
instead of http://
avoid redirect wiping out payload.
specifically, when code sent out first put request, got response of http/1.0 301 moved permanently
, , in response header correct link. code sent out second put request new link, request didn't include payload. below saw in terminal.
send: 'put /api/data/v8.0/contacts(0000000-0000-0000-0000-000000000001)/firstname http/1.1\r\nhost: example.crm.dynamics.com\r\ncontent-length: 25\r\naccept-encoding: gzip, deflate\r\naccept: */*\r\nuser-agent: python-requests/2.9.1\r\nconnection: keep-alive\r\ncontent-type: application/json\r\nauthorization: bearer sampleauthorizationtoken\r\n\r\n{"value": "webapiupdate"}' reply: 'http/1.0 301 moved permanently\r\n' header: location: https://example.crm.dynamics.com/api/data/v8.0/contacts(0000000-0000-0000-0000-000000000001)/firstname send: 'put /api/data/v8.0/contacts(0000000-0000-0000-0000-000000000001)/firstname http/1.1\r\nhost: example.crm.dynamics.com\r\ncontent-length: 0\r\naccept-encoding: gzip, deflate\r\naccept: */*\r\nuser-agent: python-requests/2.9.1\r\nconnection: keep-alive\r\ncontent-type: application/json\r\nauthorization: bearer sampleauthorizationtoken\r\n\r\n' reply: 'http/1.1 204 no content\r\n'
if scroll way right, should see top put request has data attached while bottom doesn't. why happen?
below code used generate request.
payload = {"value" : "webapiupdate"} url = "http://example.crm.dynamics.com/api/data/v8.0/contacts(0000000-0000-0000-0000-000000000001)/firstname" headers = {"authorization":"bearer "+token_response['accesstoken']} r = requests.put(url,json=payload,headers=headers)
Comments
Post a Comment