我能够使用邮递员,并使用image和string参数发出请求。如果我从邮递员那里复制python代码并运行它,我将无法执行同样的操作。
import requests
url = "yyyyyyyyyy"
querystring = {"param1":"xxxxx"}
payload = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"queryFile\"; filename=\"file.jpg\"\r\nContent-Type: image/jpeg\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--"
headers = {
'content-type': "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
'Authorization': "Bearer yyyyyyyyyyy",
'cache-control': "no-cache",
'Postman-Token': "fffffffffff"
}
response = requests.request("POST", url, data=payload, headers=headers, params=querystring)
print(response.text)
{"message":"EMPTY_FILE_NOT_ALLOWED","status":400}