我知道API调用在Postman中有效,但是当我尝试使用Postman为Python请求代码生成的代码时,它不起作用。我很确定问题是在有效负载格式化,但我看不到它。任何帮助将不胜感激。
import requests
url = "https://api.logmycalls.com/services/uploadCall"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"api_key\"\r\n\r\n***SecretAPIKey***\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"api_secret\"\r\n\r\n***SecretKey***\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"ouid\"\r\n\r\n48544\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"audio\"; filename=\"Ch6WA1WgGTpI4GbI.wav\"\r\nContent-Type: audio/x-wav\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"calldate\"\r\n\r\n2015-07-01 12:00:00\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"caller_id\"\r\n\r\n8888888888\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"ringto_number\"\r\n\r\n8888888888\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mine_call\"\r\n\r\n1\r\n-----011000010111000001101001--"
headers = {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)