Generated API add text/plain to content-type header request
See original GitHub issueDescribe the bug
Generated API hook is adding text/plain
to content-type
header.
To Reproduce Generate API using the next definition:
post:
tags:
- security
- legacy
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/MenuItems'
description: Success
operationId: postGetMenu
Headers are set as follows:
const myHook = usePostGetMenu({
requestOptions: { headers: { 'Content-Type': 'application/json', Accept: 'application/json' } }
})
And I make the request:
myHook.mutate().then((value: MenuItems) => {
console.log(value)
})
Expected behavior
I expect the request header to have content-type: application/json
and not content-type: text/plain, application/json
Desktop (please complete the following information):
- OS: Windows 10 Enterprise
- Browser Chrome 80
Thanks in advance.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:5
Top Results From Across the Web
Content-Type - HTTP - MDN Web Docs - Mozilla
In requests, (such as POST or PUT ), the client tells the server what type of data is actually sent. Header type, Representation...
Read more >How do we set content-type to "text/plain" in asp.net web api
If you explicitly want to create output and override the default content negotiation based on Accept headers you won't want to use Request....
Read more >Web API Request/Response Data Formats - Media Types
The above Web API handles HTTP POST request with JSON or XML data and parses it to a Student object based on Content-Type...
Read more >Return a plain text response to an HTTP or SDK request
For this specific use case, we set the content-type header to text/plain and returned the message export from steps.export_example (step ...
Read more >HTTP headers | Content-Type - GeeksforGeeks
HTTP headers | Content-Type ; Text, text/css text/csv text/html text/javascript (obsolete) text/plain text/xml ; Video, video/mpeg video/mp4 video ...
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 Free
Top 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
Noticed the same today. I have set
'Content-Type': 'application/json'
on the<RestfulProvider />
and I am trying to override it on the component level on myuseMutate()
hook tomultipart/form-data
but encoutered the same issue. Sent content type wasapplication/json, multipart/form-data
🤔I have the same issue. It seems impossible to replace content-type, it’s just appending the types.