Content-Type: application/json not working for multipart MIME requests #1576

ctalibard opened this Issue Apr 10, 2013 · 3 comments

3 participants


I want to be able to send two parts to my REST API, one containing RAW JSON data representing attributes of a file and a second containing the actual file.

Despite defining the Content-Type of the first part as application/json (like I would for a non-multipart request) Express is still parsing it as a string and setting a single field in req.body to contain that string.

My HTTP request is formatted like this:

Content-Type: multipart/form-data; boundary=xxxx

Content-Disposition: form-data; name="json"
Content-Type: application/json

{ some: "JSON", to: "parse" }

Content-Disposition: file; filename="theFile"
Content-Transfer-Encoding: binary

File contents here

I would hope that req.body would be the JSON I sent, but instead it's:

{ json: "{ some: \"JSON\", to: \"parse\" }" }

Is there a special Content-Disposition I should be using to make this work?


Thinking about this, it seems likely that the HTTP multi-part MIME spec/RFC just doesn't allow for anything other than form data, which is a shame.

expressjs member
tj commented Apr 10, 2013

formidable doesn't parse the parts themselves beyond files AFAIK, so for now you just get the "raw" data

expressjs member

express 3.4 now uses multiparty instead. if you want this feature, you should file an issue there.

@jonathanong jonathanong closed this Sep 7, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment