making post with multipart/form content-type
See original GitHub issueWhat is the correct way to set the headers/body to be able to make a post request with a multipart/form content-type? I can’t figure out where these should go (or where to put them):
----Z7depKeH0iSSjand
Content-Disposition: form-data; name="file"; filename="test.csv"
Content-Type: text/csv
----Z7depKeH0iSSjand
Content-Disposition: form-data; name="filename"
test.csv
----Z7depKeH0iSSjand
This is what I currently have:
const csv = makeRequest(); // does a GET, stores the csv from that response into a buffer
const opts = {
headers: {
'Content-Type': 'multipart/form-data; boundary=----Z7depKeH0iSSjand',
'Accept-Encoding': 'multipart/form-data',
'X-AUTH-TOKEN': authToken,
},
body: csv,
}
request('POST', url, opts)
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Send Data by Using a POST Method - Micro Focus
In the multipart/form-data content type, the HTTP message body is divided into parts, each containing a discrete section of data. Each message part...
Read more >POST - HTTP - MDN Web Docs
The HTTP POST method sends data to the server. The type of the body of the request is indicated by the Content-Type header....
Read more >application/x-www-form-urlencoded or multipart/form-data?
The content type "multipart/form-data" should be used for submitting forms that contain files, non-ASCII data, and binary data.
Read more >Multipart formposts - Everything curl
A multipart formpost is what an HTTP client sends when an HTML form is submitted with enctype set to "multipart/form-data". It is an...
Read more >HTTP- Understanding multipart/form-data content-type
In HTTP context, the multipart/form-data content-type is used for submitting HTML form. In the case of multipart/form-data, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Excellent, that’s exactly the right use case for this library. I am also working on supporting synchronous multi-part form upload so that should be here soon.
Hey @ForbesLindesay can you please help - I still get 415 error on this request -
const request = require(‘sync-request’) const FormData = request.FormData;