There is awesome HTTPie CLI tool. With it,is a recommended alternative to curl because you can do just
$ http POST http://example.com/some/endpoint name=value name1=value1
and so on,It speaks JSON by default and no worrieswill handle both setting the necessary header for you as well encoding data as valid JSON. There is also:
Some-Header:value
for headers, and
name==value
for query string parameters.
P.S.
IMHO, the only valid usage of curl is downloading something without persisting it, and just piping it right away to next filter. Example:
$ curl -sSL https://example.com/archive.tar.gz |tar -xzf - - you don't need to persist file if all what If you want is to immediately expand it.
$ curl -sSL https://exapmle.com/script.sh |bash - same, again, but with shell script (don't do that EVER, though).
Note, however, that by "curl" I mean command line utility, not the library. Library awesome by its own. Buthave a large chunk of data, it isyou can also why cli tool is not so usable and handy.
The best utility to just download file and persistread it with same name as remote is wget (1) (or aria2). Period. Please, don't use curl for this. When you do that,from a little pretty kitty dies somewhere in the world.file have it be JSON encoded:
The bet utility to deal with requests when you develop some king of web service (REST API, XML RPC, anything) is HTTPie. Period.
[email protected]