#10031 precludes the use of Content-Type: multipart/form-data #6894

Closed
opened 2025-12-29 19:46:27 +01:00 by adam · 2 comments
Owner

Originally created by @ctullos on GitHub (Aug 28, 2022).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.3.1

Python version

3.8

Steps to Reproduce

I recently deployed Netbox v3.3.1 to my dev environment, where I have scripts to rebuild the environment from scratch.

One of the scripts POST images to the /extras/image-attachments/ REST endpoint.

This requires Content-Type multipart/form-data which is set by the requests library given the presence of file= in the POST.

#10031 - Enforce application/json content type for REST API requests precludes the ability to POST multipart/form-data.

I reverted the changes in #10031 and had no issues with my image uploader script.

Is there a preferential or superior method to upload thousands of images? When researching/writing the existing script, suggestions were sparse.

Expected Behavior

ability to POST multipart/form-data

Observed Behavior

exception raised:

Unsupported media type \"multipart/form-data; boundary=89cv423z57692384759"

which, in my humble opinion can be as confusing as the errors #10031 seeks to address.

Originally created by @ctullos on GitHub (Aug 28, 2022). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.3.1 ### Python version 3.8 ### Steps to Reproduce I recently deployed Netbox v3.3.1 to my dev environment, where I have scripts to rebuild the environment from scratch. One of the scripts `POST` images to the `/extras/image-attachments/` REST endpoint. This requires `Content-Type` `multipart/form-data` which is set by the requests library given the presence of `file=` in the `POST`. [#10031](https://github.com/netbox-community/netbox/issues/10031) - Enforce `application/json` content type for REST API requests precludes the ability to `POST` `multipart/form-data`. I reverted the changes in [#10031](https://github.com/netbox-community/netbox/issues/10031) and had no issues with my image uploader script. Is there a preferential or superior method to upload thousands of images? When researching/writing the existing script, suggestions were sparse. ### Expected Behavior ability to POST `multipart/form-data` ### Observed Behavior exception raised: `Unsupported media type \"multipart/form-data; boundary=89cv423z57692384759"` which, in my humble opinion can be as confusing as the errors [#10031](https://github.com/netbox-community/netbox/issues/10031) seeks to address.
adam added the type: bugstatus: accepted labels 2025-12-29 19:46:27 +01:00
adam closed this issue 2025-12-29 19:46:27 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 29, 2022):

Admittedly, this was an oversight on my part. I think it makes sense to leave the default parsers list as is, and add the MultiPartParser only for endpoints which accept files (such as /api/extras/image-attachments/).

@jeremystretch commented on GitHub (Aug 29, 2022): Admittedly, this was an oversight on my part. I think it makes sense to leave the default parsers list as is, and [add](https://www.django-rest-framework.org/api-guide/parsers/#setting-the-parsers) the MultiPartParser only for endpoints which accept files (such as `/api/extras/image-attachments/`).
Author
Owner

@jeremystretch commented on GitHub (Aug 29, 2022):

To avoid confusion among plugin developers, it's probably best to include MultiPartParser by default. We can restore this while still addressing the root issue captured under #10031.

@jeremystretch commented on GitHub (Aug 29, 2022): To avoid confusion among plugin developers, it's probably best to include MultiPartParser by default. We can restore this while still addressing the root issue captured under #10031.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6894