Request items

There are a few different request item types that provide aconvenient mechanism for specifying HTTP headers, simple JSON andform data, files, and URL parameters.

They are key/value pairs specified after the URL. All have incommon that they become part of the actual request that is sent and thattheir type is distinguished only by the separator used::, =, :=, ==, @, [email protected], and :[email protected]. The ones with an@ expect a file path as value.

Item TypeDescription
HTTP HeadersName:ValueArbitrary HTTP header, e.g. X-API-Token:123.
URL parametersname==valueAppends the given name/value pair as a querystring parameter to the URL.The == separator is used.
Data Fieldsfield=value,[email protected]Request data fields to be serialized as a JSONobject (default), or to be form-encoded(—form, -f).
Raw JSON fieldsfield:=json,field:[email protected]Useful when sending JSON and one ormore fields need to be a Boolean, Number,nested Object, or an Array, e.g.,meals:='["ham","spam"]' or pies:=[1,2,3](note the quotes).
Form File Fields[email protected]/dir/fileOnly available with —form, -f.For example [email protected]~/Pictures/img.png.The presence of a file field resultsin a multipart/form-data request.

Note that data fields aren't the only way to specify request data:Redirected input is a mechanism for passing arbitrary request data.

Escaping rules

You can use \ to escape characters that shouldn't be used as separators(or parts thereof). For instance, foo\==bar will become a data key/valuepair (foo= and bar) instead of a URL parameter.

Often it is necessary to quote the values, e.g. foo='bar baz'.

If any of the field names or headers starts with a minus(e.g., -fieldname), you need to place all such items after the specialtoken to prevent confusion with —arguments:

  1. $ http httpbin.org/post -- -name-starting-with-dash=foo -Unusual-Header:bar
  1. POST /post HTTP/1.1
  2. -Unusual-Header: bar
  3. Content-Type: application/json
  4.  
  5. {
  6. "-name-starting-with-dash": "foo"
  7. }