0
RESTとpythonを使用してファイルをアップロードしたいとします。私は郵便配達員を使ってそれを行うことができます。しかし、私がPostmanからPythonコードを取得し、リクエストモジュールを使用して自分自身で実行しようとすると、私は以下のエラーを受け取ります。助けてください。"message": "要求された要求部分 'ファイル'が存在しません"
import requests
url = "https://url******"
payload = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition:
form-data; name=\"file\"; filename=\"Path to file"\r\n\r\n\r\n------
WebKitFormBoundary7MA4YWxkTrZu0gW--"
headers = {
'content-type': "multipart/form-data; boundary=----
WebKitFormBoundary7MA4YWxkTrZu0gW",
'auth_token': auth_token,
'cache-control': "no-cache",
}
response = requests.request("POST", url, data=payload, headers=headers,
verify=False)
print(response.text)
>>> response.text
u'{"message":"Required request part \'file\' is not
present","detailedMessage":"
","errorCode":-1,"httpStatus":500,"moreInfo":""}'
こんにちは、そのURLを使用してPostmanを使用してアップロードすることができます。だから、URLは問題ではありません。 –