Message 1 of 2

Not applicable
12-15-2019
08:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to send data that identifies the photoscene ID and a dictionary of locally stored files to the Autodesk Recap API. If I send only the data, the response includes the correct photoscene ID. If I include files (using the read binary option), the request does not post any data and the API cannot identify the photoscene. I have successfully created a photoscene with Python requests and uploaded the images with curl, but would prefer to do all of this in a single Python function.
headers = { 'Authorization': 'Bearer {}'.format(access_token), 'Content-Type': 'multipart/form-data' } data = { 'photosceneid': photoscene_id, 'type': 'image' } files = {} img_dir = os.listdir('Recap/') for img in img_dir: files['file[{}]'.format(img_dir.index(img))] = open('Recap/' + img, 'rb') post = requests.post(url='https://developer.api.autodesk.com/photo-to-3d/v1/file', headers=headers, data=data, files=files)
Solved! Go to Solution.