0

I can upload files and their metadata (JSON object) via postman successfully. enter image description here Image attached.

However, my Python doesn't work and it is giving an error:

import requests

url = "https://localhost:8888/dev/java-app-documents/v1/account/P00001547/documents"

payload={'metadata': '{"brand": "AB","customerNumber": "0000001","documentType": "WELCOME","EndDate": "2023-03-30T14:48:28.032Z","StartDate": "2022-03-30T14:48:28.032Z"}'}
files=[('file',('Welcomen.pdf',open('C:/Users/XXX/Downloads/Welcomen.pdf','rb'),'application/pdf'))]
headers = {"Content-type": "multipart/form-data; boundary='asdff'"}

response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.status_code, response.text)

Error is getting as :

"summary":"Generic exception","detail":"Required request part 'metadata' is not present"...
Error Code: 400
Michael M.
  • 10,486
  • 9
  • 18
  • 34
  • did you check this link: https://stackoverflow.com/questions/22567306/how-to-upload-file-with-python-requests – iliya Oct 12 '22 at 08:44
  • No it doesn't work either. I can't pass my json into data. I am getting an error as "detail":"Required request part 'metadata' is not present" – developer Oct 12 '22 at 09:19

0 Answers0