I want to convert this cURL request to a Python-Requests request since I am working on a Python wrapper for a REST service
MS_WORD_DOCUMENT=...
CONTENT_TYPE="application/msword"
JSON_REQUEST="{\"documentType\" : \"$CONTENT_TYPE\"}"
curl -X POST -F "meta=$JSON_REQUEST;type=application/json" -F "data=@$MS_WORD_DOCUMENT" $SERVICE_ENDPOINT
How can I convert this to a Python3 Requests library request?
So far I've got to
data = {"metadata": {"documentType": "application/msword",
"Content-Type": "application/json"}}
req = requests.post(
"https://text.s4.ontotext.com/v1/twitie",
auth=("user", "pass"),
headers={"Content-Type": "multipart/mixed"},
data=data,
files={"file": ("sample.docx", content,
"application/octet-stream")})
I don't know if that's the way to process multipart requests of the type with requests