I’m having trouble with the following code, and I’m not sure why it’s not working as expected. Specifically, I’m trying to upload an image to the IdentityNow API ( set-icon | SailPoint Developer Community). Here’s the relevant part of the code:
Do not manually set Content-Type to multipart/form-data:
The requests library will automatically set the correct Content-Type header with a boundary, which is crucial for proper multipart formatting.
You should remove'Content-Type': 'multipart/form-data' from headers. Otherwise, you’ll likely get a malformed request.
In the context of multipart file uploads using files=... in requests, adding data=... is only necessary if you’re also sending additional form fields along with the file (e.g., name, description, etc.).
Since your payload = {} is an empty dictionary, it has no effect whether it’s included or not.
File MIME type:
You’re using 'application/octet-stream'. It’s okay, but if you know it’s a PNG, it’s better to use 'image/png':