Comments (13)
Try this:
http 'http://httpbin.org/get?x=1&y=2'
URL with encoded parameters should be enclosed in either single ('..'
) or double (".."
) quotes if you're using shell since unescaped &
symbol is usually treated specially.
from httpie.
I know I can hand craft the URL. However I prefer httpie to do that for me, and url-encode the parameters as well.
Meaning I'll run
http GET http://httpbin.org/get x=1 y='hello there'
And httpie will translate the URL to
http://httpbin.org/get?x=1&y=hello%20there
from httpie.
The items (link y='hello there'
) are used to form request body (which definitely may present in every request including GET
). Also URL symbol escaping is supported by http. So the one and the only way is to encode URL arguments in URL and body arguments as items.
from httpie.
On one hand, it would be good to keep the data parameter semantics consistent across all HTTP method (i.e., they are used to construct the request body no matter what the method is). There isn't almost any method-specific logic in httpie, which makes it possible to issue the same request via different HTTP methods simply by changing the method name argument.
On the other hand, although it's valid, it's rather unusual for GET
requests to include a payload, but they often do contain URL parameters so it might be pragmatic to change it as tebeka proposes.
I'm not sure, though, if the pros (the ability to conveniently craft URL parameters) actually outweigh the cons (at the expense of breaking consistency).
from httpie.
You can make it explicit with a command line switch if you prefer to avoid "magic" (--args-in-url? I don't not, I stink at naming things :).
from httpie.
I have run into this issue as well, and I think that @tebeka has a good compromise solution. http ---queryparams get http://www.google.com/ q=donuts
would actually resolve to "http://www.google.com/?q=donuts", while the same command without the --queryparams
flag would just work as it already does.
I would be willing to hack this out, but I wanted to get a feel for if the change is wanted or not. Thoughts?
from httpie.
Another option would be to introduce a new separator for the querystring parameters. Perhaps something like name=:value
.
It has the advantage that it's usable with any HTTP method and the existing interface remains unchanged. On the other hand, it's not as clean and intuitive as plain name=value
would be.
from httpie.
I think name=:value
ends up being better overall for the sole reason of not breaking existing conventions. I also like that it works on any method out of the box. It seems odd to use a query string anywhere but GET, but who knows? It doesn't hurt much to leave the option open.
from httpie.
-q foo=bar
is IMHO the best thing that I can come up with. Adding any more symbols would make things confusing, so I think it's best to pick the most closely related notation. I don't think it should make ordering significant or pick up more than one following argument. So -q page=2
-q rpp=20
would be the way to get page=2&rpp=20
.
The best thing about this feature for me would be the ability to write options when I think of them, without going back to insert them.
from httpie.
@benatkin That looks better than having a flag changing the meaning of name=value
. The things is, however, that the params should intuitively go after the URL (like the rest of the key-value pairs that become part of the actual request), but all flags are expected to be at the beginning of the command.
I've merged @jakebasile's pull request (thanks!). Let's see how this feels, it can be changed before 0.2.6 final if it proves to be confusing or difficult to use.
from httpie.
The format in 0.2.6
is name==value
.
from httpie.
Great, thanks!
from httpie.
Glad it made it (in slightly altered form) into the release! 🍰
from httpie.
Related Issues (20)
- Unable to install httpie via Chocolatey HOT 14
- [macOS] Lag when piping stdout HOT 5
- Display a warning for using option --ignore-stdin when request fails with content present in stdin
- Request is fired to packages.httpie.io on every invocation of `http` HOT 1
- How to post an empty string as a data field? HOT 2
- werkzeug compatibility
- Docs: Ubuntu/Debian installation script gives error
- Does not work with a small easy peasy sample 'http -f requests.http' HOT 4
- Add shortcut to --verify=no
- Default headers by domain
- Add support for OAuth2 authentication
- Can't install a plugin because cannot invoke pip
- HTTPS_PROXY not working
- Hash character `#` in a query string causes the rest of the string to be ignored HOT 2
- Trim trailing empty lines from CLI output HOT 1
- Cryptographic API Misuse Vulnerability : Missing SSL Certificate Validation HOT 1
- Filter response keys before print result to the screen
- HTTPie could be lead to believe data was passed in stdin when it was not HOT 1
- httpie -d does not work with gzip compressed content
- Add cli option to generate scriptable or compilable code, or a native executable, that performs the command wherein the option was included
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from httpie.