How to Use HTTP Prompt in Linux

To start a session, simply run the http-prompt command as shown.

Start with the last session or http://localhost:8000
$ http-prompt

Start with the given URL
$ http-prompt http://localhost:3000

Start with some initial options
$ http-prompt localhost:3000/api --auth user:pass username=somebody
Start HTTP Prompt
Start HTTP Prompt

After starting a session, you can type commands interactively as shown in the following screenshot.

HTTP Prompt Command Usage
HTTP Prompt Command Usage

To preview how HTTP Prompt is going to call HTTPie, run the following command.

> httpie post
Preview How HTTPie is Called in HTTP Prompt
Preview How HTTPie is Called in HTTP Prompt

You can send an HTTP request, enter one of the HTTP methods as shown.

> head
> get
> post
> put
> patch
> delete
Run HTTP Methods
Run HTTP Methods

It is possible to add headersquery-string, or body parameters, use the syntax as in HTTPie. Here are some examples:

# set header
> Content-Type:application/json

# querystring parameter
> page==5

# body parameters
> username=tecmint 
> full_name='Tecmint HowTos'

# body parameters in raw JSON
> number:=45239
> is_ok:=true
> names:=["tecmint","howtos"]
> user:='{"username": "tecmint", "password": "followus"}'

# write everything in a single line
> Content-Type:application/json page==5 username=tecmint 

You can also add HTTPie options as shown.

> --form --auth user:pass
> --verify=no
> --form --auth user:pass  username=tecmint  Content-Type:application/json	

To reset the session (clear all parameters and options) or exit a session, run:

> rm *		#reset session
> exit		#exit session 

Leave a Reply

Your email address will not be published.