How to send required headers with DropzoneJs?

Viewed 1536

I am currently working on a project where I use Dropzone js to let users upload files but my status code is 400 bad request with response "Mandatory header missing!". For this request authorization header is required so I'm tried to specify it following Dropzone's docs but nothing happens. I found some solutions but it seems nothing works. Can somebody please tell me what am I doing wrong? Thank you very much!

This is my code:

     Dropzone.options.myAwesomeDropzone = {
        paramName: "files",
        maxFilesize: 2,
        autoProcessQueue: true,
        addRemoveLinks: true,
        withCredentials: true,
        acceptedFiles: ".pdf,.png,.jpg,.gif,.bmp,.jpeg",
        headers: {
            "Authorization": "Bearer " + uuid,
            "Cache-Control": null,
            "X-Requested-With": null
        }
    };

I also tried without "Cache-Control": null, "X-Requested-With": null

Request headers in dev tools are:

Accept:application/json
Cache-Control:no-cache
Connection:keep-alive
Content-Length:95768
Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryjP8HZAwoxuL5kHB4
X-Requested-With:XMLHttpRequest
** More headers like HOST COOKIE... **

And request payload is:

------WebKitFormBoundaryjP8HZAwoxuL5kHB4
Content-Disposition: form-data; name="file"; filename="test.pdf"
Content-Type: application/pdf

------WebKitFormBoundaryjP8HZAwoxuL5kHB4--
0 Answers
Related