Uploading a local image using the API

I spent quite some time trying to figure out how to invoke the upload endpoint from a Python script. I first followed the recommendation to reverse engineer the upload API call through Chrome dev tools. Next I replicated the upload call via Postman. Time consuming part for me was to translate that to a working Python code. For some reason, the Postman-generated Python code wasn’t working either. Here’s how it finally worked for me:

requests.post('/uploads.json', files={'files[]': open('/path/to/image.png', 'rb')}, data={'type': 'composer'})