multipart/form-data upload receives bad request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to upload a file to Canvas using the API. I'm on the second step where you construct the multipart form and POST it but I'm getting a 400 Bad Request error every time with nothing else to give me a clue as to what is wrong.
I post to the url I receive from the first step.
Anybody have an idea as to why it's giving me a bad request?
How can I find out why it's giving me a 400 Bad Request?
Thanks in advance.
Here is my multipart/form-data before it's converted to binary:
Content-Type: multipart/form-data; boundary=----------b3323d8480cf4a5f89f36e1680263e49
------------b3323d8480cf4a5f89f36e1680263e49\r\n
Content-Disposition: form-data; name=\"fileToUpload\"; filename=\"profile_picture.jpg\"\r\nContent-Type: image/jpeg\r\n\r\n
------------b3323d8480cf4a5f89f36e1680263e49\r\n
Content-Disposition: form-data; name=\"key\"\r\n\r\naccount_<account id>/attachments/<account id>/profile_picture.jpg
------------b3323d8480cf4a5f89f36e1680263e49\r\n
Content-Disposition: form-data; name=\"x-amz-credential\"\r\n\r\nAKIAJKYS55LTKAJVWK3Q/20181113/eu-west-1/s3/aws4_request
------------b3323d8480cf4a5f89f36e1680263e49\r\n
Content-Disposition: form-data; name=\"x-amz-algorithm\"\r\n\r\nAWS4-HMAC-SHA256
------------b3323d8480cf4a5f89f36e1680263e49\r\n
Content-Disposition: form-data; name=\"x-amz-date\"\r\n\r\n20181113T075946Z
------------b3323d8480cf4a5f89f36e1680263e49\r\n
Content-Disposition: form-data; name=\"Filename\"\r\n\r\nprofile_picture.jpg
------------b3323d8480cf4a5f89f36e1680263e49\r\n
Content-Disposition: form-data; name=\"acl\"\r\n\r\nprivate
------------b3323d8480cf4a5f89f36e1680263e49\r\n
Content-Disposition: form-data;name=\"Policy\"\r\n\r\neyJleHBpcmF0aW9uIjoiMjAxOC0xMS0xM1QwODoyOTo0NloiLCJjb25kaXRpb25zIjpbeyJidWNrZXQiOiJpbnN0cnVjdHVyZS11cGxvYWRzLWV1In0seyJrZXkiOiJhY2NvdW50XzgxMDQwMDAwMDAwMDAwMDAxL2F0dGFjaG1lbnRzLzM3MTE0NS9wcm9maWxlX3BpY3R1cmUuanBnIn0seyJhY2wiOiJwcml2YXRlIn0sWyJzdGFydHMtd2l0aCIsIiRGaWxlbmFtZSIsIiJdLFsiY29udGVudC1sZW5ndGgtcmFuZ2UiLDEsMTA3Mzc0MTgyNDBdLHsieC1hbXotY3JlZGVudGlhbCI6IkFLSUFKS1lTNTVMVEtBSlZXSzNRLzIwMTgxMTEzL2V1LXdlc3QtMS9zMy9hd3M0X3JlcXVlc3QifSx7IngtYW16LWFsZ29yaXRobSI6IkFXUzQtSE1BQy1TSEEyNTYifSx7IngtYW16LWRhdGUiOiIyMDE4MTExM1QwNzU5NDZaIn0seyJzdWNjZXNzX2FjdGlvbl9yZWRpcmVjdCI6Imh0dHBzOi8vZGlzYWJyb2FkLnRlc3QuaW5zdHJ1Y3R1cmUuY29tL2FwaS92MS9maWxlcy8zNzExNDUvY3JlYXRlX3N1Y2Nlc3M/dXVpZD1aQ1FzcEpqY0l2STN6UEtBTFl1a3JqMlJPY1JPNzNDRFdpMnY5Y0N1In0seyJjb250ZW50LXR5cGUiOiJpbWFnZS9qcGVnIn1dfQ==
------------b3323d8480cf4a5f89f36e1680263e49\r\n
Content-Disposition: form-data; name=\"x-amz-signature\"\r\n\r\ndd7cde0c122f6f5d437d2b6b2b37619dc8cbe4acccad21d9a11da1d809cec853
------------b3323d8480cf4a5f89f36e1680263e49\r\n
Content-Disposition: form-data; name=\"success_action_redirect\"\r\n\r\nhttps://disabroad.test.instructure.com/api/v1/files/371145/create_success?uuid=ZCQspJjcIvI3zPKALYukr...
------------b3323d8480cf4a5f89f36e1680263e49\r\n
Content-Disposition: form-data; name=\"content-type\"\r\n\r\nimage/jpeg
------------b3323d8480cf4a5f89f36e1680263e49\r\n
Content-Disposition: form-data; name=\"file\"\r\n\r\nprofile_picture.jpg\r\n
------------b3323d8480cf4a5f89f36e1680263e49--\r\n