You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My understanding is in order to upload a document I need to provide an attachmentcontents parameter that is a path to a file on disk, but I don't see how the POST method would leverage that to include the file contents. All my attempts get "error": "Unable to attach uploaded document."
The text was updated successfully, but these errors were encountered:
EDIT:
The link above used to work when it was posted. Try this code snippet:
#!venv/bin/python
#import the request library
import requests
#open the test.txt file in binary mode
file = open('test.txt', 'rb')
#provide the URL you want to upload to
url = 'https://example.com/api/files/'
#set the auth token for the POST route, your POST route shoudl be secured
headers = {'token': 'c203x302s30s03x0322x0320'}
#if you have data to send with the file you add it to the payload here
payload = {'client_id': 1}
#assign a file to the files dictionary
files = {'file': file}
#call the post method of the request and store the response in the r variable
r = requests.post(url, files=files, data=payload, headers=headers)
#if your server sends a response here you decode it to json
json_data = r.json()
# print your response json
print(json_data)
My understanding is in order to upload a document I need to provide an
attachmentcontents
parameter that is a path to a file on disk, but I don't see how thePOST
method would leverage that to include the file contents. All my attempts get"error": "Unable to attach uploaded document."
The text was updated successfully, but these errors were encountered: