-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Request to add -d, --data
option for raw body like curl
#534
Comments
There'd be nothing particularly wrong with that. I just find piping cleaner and strongly prefer when there is only one way of doing the same thing. Piping exists for this very purpose (i.e. to pass data to programs), and It's easy to understand, universal, and unambiguous. Every decent CLI tool supports piping (with the notable exception of Compare: httpie
curl
|
Yes, I agree with you that support piping in a command line tool is a good feature, and also I made a command line tool that supports piping ( Mongotail ), and to be honest I didn't know that |
The commands you mention do generally accept either a filename argument list or raw input data through (Clarifying what I wrote in an earlier comment: |
Came here to file a bug related to this issue, so maybe it's not a bug but working as designed. I have a bash script I was changing to use "httpie" instead of "curl". The requests are empty-body POSTs to an http server. I run this script by piping it into a I had a hard time figuring out that the I guess it's something about
|
(@jamshid you |
Am I right in thinking that 15.1 Request data from a filename covers this issue's original request? I guess this issue can be closed. As an aside, I wish I'd known about HTTPie before yesterday as I would've avoided 3 hours or so working out why line breaks in my XML file weren't being preserved. (I thought it was my app but it was curl, which requires its |
It does not, @DavidOliver . @mrsarm requested to be able to pass a string from parameter, not contents of a file. |
+1 |
Would you accept MR with this feature @jakubroztocil ? |
you can just do |
http :/api/hey say=Hello to=me … |
seemed not work for powershell, |
according to the docs you can use a "Bash here string":
|
UX-wise, the option makes sense. |
i can't seem to find a way to send an empty json object ( |
$ echo '{}' | http httpbin.org/post |
any way to discard the newline while redirecting? $ echo 20 | http POST httpbin.org/post the data filed would be |
@hahattan you can instruct $ echo -n foo | http httpbin.org/post |
@jakubroztocil Thank you, I was about to open an issue about the newlines |
Do you mind having a look at #1063 🙏 ? :) |
Implemented: https://httpie.io/docs#raw-request-body |
Just wanted to say that I'm pleased to see this feature finally included in the last release, thanks @jakubroztocil 👏 |
The request is simple, just to add an option to pass raw data like
curl
does:I know that in mostly cases if you are sending JSON or form data, it can be achieved with the "request items", like:
And it will converted to the proper format depending of the content type, that is awesome! And if you have something that is not a JSON or form data to send, you can do something like:
But this is impractical, the main idea of HTTPie is cURL-like tool for humans , and this case is far of that principle, in fact,
curl
is more practical than HTTPie for the previous example. Adding more than one command and pipe them with ugly characters like|
<
just because a simple option is missing doesn't sound human-friendly.What's wrong with add the
-d
option tohttp
?The text was updated successfully, but these errors were encountered: