PROBLEM
Trying to send a multipart/formdata post request with a file upload and model data in JSON. Not sure why there are not much working references, couldn't make work the ones which are there. Might be doing something wrong as well or making it more complicated too.
REFS TRIED
- uploading-files-and-json-data-in-the-same-request-with-angular-js
- a nice explanation about boundary and multipart
- some so question
QUESTION
Somehow json content on my post request payload doesn't seem to contain Content-Type: application/json identified automatically.
Even setting the content-type as undefined/false for the POST didnt work. Need some suggestion on what would be the problem or how to fix this?
NETWORK LOG FOR FIDDLE UPLOAD
Request Headers
Accept:application/json, text/plain, */*
Content-Length:361
Content-Type:multipart/form-data; boundary=----WebKitFormBoundary7NukqN6GtRwugBSJ
Request Payload
------WebKitFormBoundary7NukqN6GtRwugBSJ
Content-Disposition: form-data; name="file"; filename="sample.csv"
Content-Type: text/csv
------WebKitFormBoundary7NukqN6GtRwugBSJ
Content-Disposition: form-data; name="data"
{"name":"a good name","comments":"some comments"}
------WebKitFormBoundary7NukqN6GtRwugBSJ--