Manually set content-type when using .attach
See original GitHub issueHey! I’m sending a request like this
request
.post('http://website.com/upload')
.attach('image', path)
.send(payload)
.set('content-type', 'multipart/form-data; boundary=----WebKitFormBoundaryKWf3FhTklvtPkprk')
However, the content-type gets overridden by superagents own value. Resulting in a res.req._headers like this
content-type': 'multipart/form-data; boundary=--------------------------442535245526379898253153
Is there any way i can force set the content-type manually?
Or perhaps figure out superagents content-type pre-post so i can use the same boundary in my .send(payload)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Manually set content-type when using .attach #1152 - GitHub
Hey! I'm sending a request like this request .post('http://website.com/upload') .attach('image', path) .send(payload) .set('content-type', ...
Read more >How do you set the Content-Type header for an HttpClient ...
I tried creating a new StringContent with the three parameters and it didn't work. I then manually: request.Content.Headers.Remove("Content-Type") and then: ...
Read more >Content-Type - HTTP - MDN Web Docs - Mozilla
In responses, a Content-Type header provides the client with the actual content type of the returned content. This header's value may be ...
Read more >Solved: Update Content-Type in Attachment before submissio...
hello, I have set resource root as ${projectDir} and i am not attaching files manually and using groovy script instead. And i've tried ......
Read more >How to add Content-Type for income request by conditions ...
Put a separate MPGW in front of this one, which only sets the Content-Type header as needed, then sends the request to your...
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
You can’t use
attach()
andsend()
at the same time. You can either use your own content-type and your own payload with.send().set()
OR you can let all of it being 100% auto-generated by the browser by using.attach().field()
. They don’t mix.Please make a new issue for the other problem