I want to query a REST API with HTTPie. I am usuale to do so with curl, with which I am able to specify maxKeys
and startAfterFilename
e.g.
curl --location --request GET -G \
"https://some.thing.some.where/data/v1/datasets/mydataset/versions/2/files" \
-d maxKeys=100 \
-d startAfterFilename=YYYMMDD_HHMMSS.file \
--header "Authorization: verylongtoken"
How can I use those -d
options in HTTPie?
CodePudding user response:
In your case the command looks like this:
http -F https://some.thing.some.where/data/v1/datasets/mydataset/versions/2/files \
Authorization:verylongtoken \
startAfterFilename=="YYYMMDD_HHMMSS.file" \
maxKeys=="100"
Although, there is a bunch of methods to pass some data with httpie
. For example
http POST http://example.com/posts/3 \
Origin:example.com \ # : HTTP headers
name="John Doe" \ # = string
q=="search" \ # == URL parameters (?q=search)
age:=29 \ # := for non-strings
list:='[1,3,4]' \ # := json
[email protected] \ # @ attach file
[email protected] \ # =@ read from file (text)
user:[email protected] # :=@ read from file (json)
Or, in the case of forms
http --form POST example.com \
name="John Smith" \
[email protected]