json: true sends "true" as request body no matter what
See original GitHub issuexhr({body: {foo: 'bar'}, json: true})
will post true
as request body.
It even sends false
as request body if passing json: false
.
According to request
docs, the json flag is only used as a modifier to body
:
json - sets body to JSON representation of value and adds Content-type: application/json header. Additionally, parses the response body as JSON. (https://github.com/request/request/blob/master/README.md#requestoptions-callback)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
JSON Post request for boolean field sends false by default
When you are using libraries like lombok to generate getters and setters, don't add 'is' with the field name if the field type...
Read more >Sending boolean as body for JSON request not working properly
Yes, not sending a body and having json: true works fine. Setting body: null is what causes the issue since what was previously...
Read more >5.x API - Express.js
Enables or disables handling deflated (compressed) bodies; when disabled, deflated bodies are rejected. Boolean, true. limit, Controls the maximum request body ...
Read more >Accepting Raw Request Body Content in ASP.NET Core API ...
I'm essentially doing the same thing as in the first request, except I'm not sending JSON content type but plain text.
Read more >ansible.builtin.uri module – Interacts with webservices
The body of the http request/response to the web service. ... true. force_basic_auth. boolean. Force the sending of the Basic authentication header upon ......
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
Hey, sorry if this is late to the party, or if I missed anything somewhere in #136, but it seems to me like this not working is a bug in the current branch that can be fixed before a major version bump. Something like this could fix it until #135 goes through:
This bug blocks a bunch of legitimate use cases (body-less DELETE requests which expect json back, for example) in the 2.0 branch, and so I think holding up a release here is a mistake, but that is just my personal opinion.
I can submit the PR for this if it seems like a good change
merged, releasing 2.3.0