![]() ![]() However, API requests make structured calls between two computers. This doesn't depend much on structured responses. Http -session=/tmp/session.json http -session=/tmp/session.json -session=~/.httpie/sessions//test.json http -session-read-only=/tmp/session.json example.Website requests are designed to be between a computer and an end user who is reading and responding to what they see. This allows for sessions to be re-used across multiple hosts: # Instead of a name, you can also directly specify a path to a session Http -session=user2 -a user2:password X-Bar:Foo # To create or reuse a different session, simple specify a different name: # authorization and HTTP headers will automatically be set: # Now you can refer to the session by its name, and the previously used Http -session=user1 -a user1:password X-Foo:Bar Http -stream -f -a YOUR-TWITTER-NAME track=Apple | while read tweet do echo "$tweet" | http POST /tweets done # server as soon as it arrives from the Twitter streaming API: # Send each new tweet (JSON object) mentioning "Apple" to another Http -stream -f -a YOUR-TWITTER-NAME track='Justin Bieber' # support that, the whole file will simply be downloaded: # Range requests and 206 Partial Content responses. This only works with servers that support # If -output, -o is specified, you can resume a partial download using # response headers and progress are still shown in the terminal: # You can also redirect the response body to another program while the # to the terminal (stderr), and a progress bar is shown while the response # When enabled using the -download, -d flag, response headers are printed # Force colorizing and formatting, and show both the request and the Http /images/original.jpg | convert -resize 25% - | http /Octocats # Download an image of Octocat, resize it using ImageMagick, upload it # the following request sends the verbatim contents of that XML file with # to the appropriate value based on the filename extension. # It has the advantage that THE Content-Type HEADER IS AUTOMATICALLY SET # whose content is used as if it came from stdin. # AN ALTERNATIVE TO REDIRECTED stdin is specifying a filename (as # Passing data through stdin cannot be combined with data fields specifiedĮcho 'data' | http POST more=data # This is invalid # On OS X, you can send the contents of the clipboard with pbpaste: Http PUT /person/1 X-API-Token:123 Ĭat | http POST /todos Content-Type:text/plain Http -headers PATCH /Really-Huge-Resource name='New Name' # is updated, but you are only interested in the response headers to see # Let's say that there is an API that returns the whole resource when it ![]() # -print, -p Selects parts of the HTTP exchange. # -verbose, -v Print the whole HTTP exchange (request and response). # -body, -b Only the response body is printed. # -headers, -h Only the response headers are printed. # You can control what should be printed via several options: Http -cert=client.crt -cert-key=client.key # If the PRIVATE KEY is not contained in the cert file you may pass the # To use a CLIENT SIDE CERTIFICATE for the SSL communication, you can pass Http POST /person/1 to set a CUSTOM CA BUNDLE path: # embedded into fields using and PUT /person/1 name=John age:=29 married:=false hobbies:='' Send JSON data stored in a file: Http PUT name=John Non-string fields use the := separator, which allows you to embed raw # Set a custom Host header to work around missing DNS records: # http -session=logged-in -a username:password /get API-Key:123 # persistent between requests to the same host: # Use named sessions_ to make certain aspects or the communication Http -a USERNAME POST body='HTTPie is awesome!' # Use Github API to post a comment on an issue with authentication: # See the request that is being sent using one of the output options: ![]() # Custom HTTP method HTTP headers and JSON data: # To follow redirects and show intermediary requests and responses: ![]() # To show the whole HTTP exchange (both request and response): # To send a DELETE request with a given request header: # To send a PUT request with a given JSON body: # To send a POST request with redirected input: # To send a POST request (default method with request data): # To send a GET request (default method with no request data): ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |