question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generated API add text/plain to content-type header request

See original GitHub issue

Describe 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 image

Desktop (please complete the following information):

  • OS: Windows 10 Enterprise
  • Browser Chrome 80

Thanks in advance.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:5

github_iconTop GitHub Comments

1reaction
valstucommented, Mar 9, 2021

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 my useMutate() hook to multipart/form-data but encoutered the same issue. Sent content type was application/json, multipart/form-data 🤔

1reaction
AsasInnabcommented, Mar 5, 2021

I have the same issue. It seems impossible to replace content-type, it’s just appending the types.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found