I'm trying to post an image to an API, where it image is a URI supplied by another service:
import requests
input_data = {
"employeeId": 123,
"picture_uri": 'https://mw1.google.com/crisisresponse/icons/un-ocha/cluster_CCCM_100px_icon_bluebox.png'
}
# retrieve image from URI
r = requests.get(input_data['picture_uri'])
# create dictionary
file = {'photo': r.content}
uri = f"https://api.bamboohr.com/api/gateway.php/subdomain/v1/employees/{input_data['employeeId']}/photo"
response = requests.post(uri, auth=('account','password'), files=file)
print(response.status_code) # 400
What am I missing?
** edit **
Documentation indicates that the POST needs to be a multipart/form-data
: https://documentation.bamboohr.com/reference/upload-employee-photo-1