Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--json without request items omits body instead of sending empty object #1263

Closed
2 tasks done
blyxxyz opened this issue Jan 9, 2022 · 2 comments
Closed
2 tasks done
Labels
bug Something isn't working needs product design We like the idea, but we want to explore the problem deeper, and consider the solution holistically

Comments

@blyxxyz
Copy link
Contributor

blyxxyz commented Jan 9, 2022

Checklist

  • I've searched for similar issues.
  • I'm using the latest version of HTTPie.

Minimal reproduction code and steps

Run http --offline --json post :

Current result

A request with Content-Type: application/json and an empty body is sent.

Expected result

{} is sent as a body.


It seems to me that HTTPie shouldn't construct an invalid JSON body if it picks a JSON content type.

(Without the --json flag no Content-Type header is sent, so everything's fine.)

See also:

@blyxxyz blyxxyz added bug Something isn't working new Needs triage. Comments are welcome! labels Jan 9, 2022
@isidentical isidentical added needs product design We like the idea, but we want to explore the problem deeper, and consider the solution holistically and removed new Needs triage. Comments are welcome! labels Jan 11, 2022
@isidentical
Copy link
Contributor

Thanks for the report @blyxxyz, but we have concluded that this might not be very intuitive (adding a different behavior when a default option is specified explicitly). I think the easiest route is just sending it with --raw, e.g http --offline pie.dev/get --raw="{}".

@blyxxyz
Copy link
Contributor Author

blyxxyz commented Mar 25, 2022

#137 already decided opposite by making explicit --json add a Content-Type header, so then maybe that should be reverted instead? Right now it's inconsistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs product design We like the idea, but we want to explore the problem deeper, and consider the solution holistically
Projects
None yet
Development

No branches or pull requests

2 participants