есть код на powershell:
$LoadDocumentUri = "api/common/v1/documents"
$File = "C:\apptest\activate.pdf";
$Boundary = [System.Guid]::NewGuid().ToString();
$File1 = [IO.FILE]::ReadAllBytes($File);
$bodylines = @(
"--$boundary",
"Content-Disposition: form-data; name=`"files`"; filename=`"activate.pdf`"",
"Content-Type: application/octet-stream$LF",
$File1,
"--$boundary",
"Content-Disposition: form-data; name=`"metadata`"",
"Content-Type: application/json$LF",
$metadata
"--$boundary--$LF"
) -join $LF
$ContentType = "multipart/form-data; boundary=`"$boundary`""
Пытаюсь переделать его на python и получаю 500 ошибку от сервера:
import requests
url = "https://auto.ru/api/common/v1/documents" #адрес не публичный во внутренней сети
payload={'metadata': '{"requestId":"00000000-0000-0000-47ad-7b37414f381b","uploadTarget":"1","fileType":"102"}'}
files=[('files', open('activate.pdf','rb'))]
headers['Content-Type']='application/octet-stream'
response = requests.request("POST", url, headers=headers, data=payload, files=files,verify=False)
print(response)
В чем может быть причина?
$LoadDocumentUri = "api/common/v1/documents"
$File = "C:\apptest\activate.pdf";
$Boundary = [System.Guid]::NewGuid().ToString();
$File1 = [IO.FILE]::ReadAllBytes($File);
$bodylines = @(
"--$boundary",
"Content-Disposition: form-data; name=`"files`"; filename=`"activate.pdf`"",
"Content-Type: application/octet-stream$LF",
$File1,
"--$boundary",
"Content-Disposition: form-data; name=`"metadata`"",
"Content-Type: application/json$LF",
$metadata
"--$boundary--$LF"
) -join $LF
$ContentType = "multipart/form-data; boundary=`"$boundary`""
Пытаюсь переделать его на python и получаю 500 ошибку от сервера:
import requests
url = "https://auto.ru/api/common/v1/documents" #адрес не публичный во внутренней сети
payload={'metadata': '{"requestId":"00000000-0000-0000-47ad-7b37414f381b","uploadTarget":"1","fileType":"102"}'}
files=[('files', open('activate.pdf','rb'))]
headers['Content-Type']='application/octet-stream'
response = requests.request("POST", url, headers=headers, data=payload, files=files,verify=False)
print(response)
В чем может быть причина?