Building requests

A request is a method, a URL, headers, query parameters, an optional authorization, an optional body, two optional scripts and free notes. This page covers each part as you see it in the request editor, and how it is stored in the file.

Method

Click the method at the left of the URL bar to pick GET, POST, PUT, PATCH, DELETE, HEAD or OPTIONS. Each standard method has its own color in the sidebar and the tabs.

Custom methods

Choose Custom… and type any token, such as PURGE, PROPFIND or REPORT. Press Enter to confirm. A custom method may contain uppercase letters, digits and symbols but no lowercase letter: M3THOD is valid, purge is not. While the token is invalid, Enter keeps the editor open so you can fix it, and clicking away discards it.

URL

Type the full URL: https://api.example.com/v1/users. Without a scheme, Postino sends it over plain HTTP, so localhost:8080/users is sent as http://localhost:8080/users; type https:// when you need it. A URL that starts with a variable with no value, such as {{baseUrl}}/users with no environment selected, is left as it is, since the variable usually holds the scheme. The file keeps the URL as you typed it. Use {{variables}} anywhere in it, typically for the host: {{baseUrl}}/v1/users. Type {{ or press Ctrl Space to pick a variable from a menu, see autocompleting variables. Variables are drawn as chips. A chip for a variable that does not resolve in the active environment is red; click it to define the variable. See defining a variable from a request.

The URL may already include a query string (/search?q=books). Entries from the Params tab are appended to it when the request is sent.

Query parameters

The Params tab is a table of keys and values. Click Add to add a row, the checkbox to switch a row off without deleting it, and the remove button to delete it. Pressing Tab in the value of the last row also adds a row and puts the cursor in its key, unless that last row is still empty. Click the Key or Value header to sort the rows by that column, from A to Z, and click it again for Z to A. Sorting moves the rows themselves, so it changes the order in which they are sent and saved; numbers inside names sort by value, so item2 comes before item10. An arrow next to the header shows the order until you edit the rows out of it. The Headers and Form tables work the same way.

  • Enabled rows are appended to the URL when the request is sent, in table order, with ? or & as needed.
  • Keys and values are percent-encoded for you, after variables are replaced. Write q = rust books, and q=rust%20books is sent.
  • A row with a key and no value is sent as key=.
  • Editing the URL by hand does not change the Params table, and the table does not rewrite the URL bar. The two are combined only when sending.
books/search.postino
GET {{baseUrl}}/books

::: query
genre = science-fiction
limit = 20
# inStock = true

In the file, a disabled row is a line starting with #. The request above is sent as GET {{baseUrl}}/books?genre=science-fiction&limit=20.

Headers

The Headers tab works like Params: add rows, switch them on and off, remove them. Header names and values can contain variables. In the file, headers are the lines right after the request line, written as Name: value, and a disabled header starts with #:

GET {{baseUrl}}/me
Accept: application/json
Authorization: Bearer {{token}}
# X-Debug: 1

Headers are sent in the order they appear. The order is kept exactly as written when the file is saved.

Suggested headers

The Headers table suggests common headers while you type, in a menu below the cell:

  • In a name, part of it lists the matching common request headers, ignoring case, names that start with it first: Acc offers Accept, Accept-Encoding, Accept-Language and the rest.
  • In a value, part of it lists the usual values of that header. Content-Type and Accept offer media types such as application/json, application/json; charset=utf-8, application/xml, text/plain, application/x-www-form-urlencoded and multipart/form-data (Accept also */*). Authorization offers Bearer and Basic , and Cache-Control, Accept-Encoding, Connection, Prefer and others offer their usual values too.
  • A suggestion replaces the whole cell, in its usual spelling. The menu closes when the cell already holds one of the suggestions or nothing matches, so your own headers are never in the way.
  • Ctrl Space opens the menu on demand, listing every suggestion when the cell is empty or complete. In a value it lists the header's values first and then the variables, which are inserted at the cursor. Typing {{ lists only the variables, see autocompleting variables.
  • The keys are the same as for variables: ↑ and ↓ to move, Enter, Tab or a click to insert, Esc to close.
  • The Name of an API key in the Auth tab suggests the same header names while it is sent as a header (with X-API-Key and Api-Key among them), and none while it goes in the query.

Automatic headers

  • Content-Type: when the body is JSON, XML or Form and you have not set a Content-Type header yourself (in any letter case), Postino adds application/json, application/xml or application/x-www-form-urlencoded. A Text body gets no automatic content type: set one if your API needs it.
  • The HTTP client adds the usual transport headers, such as Host and Content-Length.

Authentication

The Auth tab starts with a selector: None, Basic, Bearer, API key or OAuth 2.0. Each type shows its own fields, and Postino builds the header for you when the request is sent:

TypeFieldsSent as
BasicUsername, PasswordAuthorization: Basic and the Base64 of username:password
BearerTokenAuthorization: Bearer <token>
API keyName, Value, Add to (Header or Query param)A header, or a query parameter added after the Params entries
OAuth 2.0Profile, ScopeThe token of the profile for the active environment, obtained or renewed on Send, see OAuth 2.0
NoneNothingNothing
  • Every field takes {{variables}} and template functions, with the same chips and autocompletion as the Params and Headers values. The password, the token and the API key value are shown as dots, except the {{variables}} in them, and the values of their variables are hidden in tooltips and menus.
  • The API key Name suggests common header names while Add to is Header, like the names of the Headers table, see suggested headers.
  • The eye button at the end of a masked field shows its text, and clicking it again hides it. It applies to the tab, not to the file: the fields are masked again when the request is opened again.
  • Variables are replaced before the Basic credentials are encoded, so {{username}} and {{password}} work as they are.
  • A new API key starts with X-API-Key as its Name, the most common header for one. Change it if the API expects another.
  • Nothing is sent while the field a type needs is empty: the token, the API key name, or both the username and the password.
  • A header you write yourself in the Headers tab wins: with an enabled Authorization header (in any letter case), Basic and Bearer add nothing, and the Auth tab says The Authorization header of the Headers tab is sent instead. The same goes for an API key and an enabled header with its name, or an enabled Params entry with its name when it goes in the query.
  • Switching the type keeps what the other types held while the tab is open, so switching back brings the fields back. Only the type selected when you save is written to the file.
  • The auth is applied after the pre-request script, so a token the script sets with vars.set() reaches {{token}}. See the script API.

In the file it is the ::: auth section, one field = value line per field:

users/me.postino
GET {{baseUrl}}/me

::: auth bearer
token = {{token}}
reports/daily.postino
GET {{baseUrl}}/reports/daily

::: auth apikey
name = api_key
value = {{apiKey}}
in = query

A plain Authorization: Bearer {{token}} header still works the same. To log in once and reuse the token, see log in once, reuse the token. For OAuth 2.0, see OAuth 2.0.

Body

The Body tab starts with a selector: JSON, Text, XML, Form or None.

TypeEditorSent asIn the file
JSONCode editor with JSON highlighting and a Format buttonThe text, Content-Type: application/json by default::: body json
TextPlain code editorThe text, no default content type::: body text
XMLCode editor with XML highlightingThe text, Content-Type: application/xml by default::: body xml
FormKey and value tableURL encoded fields, application/x-www-form-urlencoded::: body form
MultipartKey and value tableThe fields as multipart/form-data, with a generated boundary. See Multipart bodies::: body multipart
NoneNothingNo bodyNo body section
  • Switching between JSON, Text and XML keeps what you typed, so you can switch to Text while a JSON body is not valid yet. Form fields and the text are kept apart while the tab is open: switching from Form to JSON and back brings the fields back, and switching to None or Form and back brings the text back. Only the type selected when you save is written to the file.
  • Format pretty prints a JSON body with the JSON indentation of Settings, two spaces by default. It only changes the whitespace: keys keep their order, and numbers and escapes stay as you typed them. It is enabled only for JSON bodies, and does nothing to a body that is not valid JSON yet, such as one with a variable outside a string. Ctrl Z in the body undoes it like any other edit.
  • Variables and template functions work inside any body. In a JSON body, put them inside strings when the value is a string: "name": "{{userName}}". A defined variable shows in the accent color and an undefined one with a red wavy underline; point at a defined one to see its value and where it comes from.
  • The JSON, Text and XML editor has the find bar (Ctrl F), folding, and a right-click menu with Duplicate line, Delete line and Wrap lines. A text body wraps its lines; JSON and XML do not until Alt Z.
  • Like the response body, the editor draws a line between the line numbers and the text and a vertical guide at each indentation level. In an XML body, the name of the tag under the cursor and of its opening or closing pair are highlighted.
  • Form fields are encoded after variables are replaced. Spaces become +, as servers expect for this content type. Disabled fields are not sent.
users/create.postino
POST {{baseUrl}}/users

::: body json
{
  "name": "{{userName}}",
  "email": "{{userEmail}}",
  "requestId": "{{ uuid() }}"
}
auth/token.postino
POST {{authUrl}}/oauth/token

::: body form
grant_type = client_credentials
client_id = {{clientId}}
client_secret = {{clientSecret}}
# scope = read write

Multipart bodies

A Multipart body sends its fields as multipart/form-data, the usual way to upload files. A value that starts with @ sends a file: the part carries the file's name and its contents as application/octet-stream. A relative path starts at the workspace folder, so uploads can be versioned next to the requests. Write @@ for a value that really starts with @. Variables work in names and values, the path included.

POST {{baseUrl}}/documents

::: body multipart
title = Invoice {{month}}
handle = @@acme
file = @fixtures/invoice.pdf

Postino sets the Content-Type header with the boundary. A Content-Type: multipart/form-data header you wrote without a boundary gets it added. A file that cannot be read stops the send and the response panel says which one. The file is read on every send, and the Code snippet dialog names the file but leaves its contents out. In a pre script, req.body is the enabled fields as key=value pairs separated by &, as in a form.

Scripts

The Pre-request tab holds JavaScript that runs before the request is sent; it can change the method, URL, headers and body, and set variables. The Post-response tab runs after the response arrives; it can check the response with tests and store values for later requests. Both are covered in Scripts and tests.

Docs

The Docs tab is an editor for notes, with line numbers, Markdown colors and long lines wrapped: what the endpoint does, the permissions it needs, a link to the API reference. It has the same find bar (Ctrl F), folding of sections and right-click menu as the response body, and Ctrl Z undoes its own edits. It is stored as Markdown in the ::: docs section and never sent. It shows in the file, so it also helps anyone reading the request on GitHub.

Sending

Press Send or Ctrl Enter (⌘ Enter on macOS). Postino runs these steps, in order:

  1. Variables. Collects the active environment and the variables set by scripts during this session.
  2. Pre-request script. Runs it, if any. An error here stops the run and the request is not sent.
  3. Interpolation. Replaces every {{ }} marker in the URL, query, headers and body, adds http:// to a URL without a scheme, and appends the query parameters.
  4. HTTP. Sends the request and reads the response.
  5. Post-response script. Runs it, if any. An error here is reported, but the response is still shown.

Send uses what is in the editor, even if it is not saved. While the request is in flight, the button turns into Cancel. Sending again, or cancelling, drops the request in flight.

Network behavior

AspectBehavior
Timeout30 seconds for the whole exchange, from connecting to reading the last byte, redirects included.
RedirectsFollowed automatically, up to 10. The response shown is the final one.
Error statusesA 4xx or 5xx response is a normal response, shown with its body. Only failures that leave no response at all (bad URL, DNS, connection refused, timeout, too many redirects) are errors.
TLSHTTPS through rustls, or the system's TLS library for servers that only offer outdated TLS. What happens with an invalid certificate is a setting: send with a warning (default), reject, or accept silently.
Response sizeBodies up to 20 MB by default. A bigger one fails with a clear error. The limit is a setting.
CompressionPostino asks for gzip and decompresses the body for you. The size shown is the decompressed size.
CookiesNot stored between requests. Set a Cookie header, or save a value from Set-Cookie in a post-response script.
ProxyNo proxy setting in the app. The standard environment variables are honored: HTTPS_PROXY, HTTP_PROXY, ALL_PROXY (also in lowercase) and NO_PROXY, read when Postino starts.

Saving

Any change marks the tab with a dot and shows Unsaved changes in the status bar. Press Ctrl S to write the file. Postino writes the file in its canonical form, so saving a request you did not change produces no diff, and the order of sections is always the same. See the file format.

Undo and redo

Every request tab keeps its own history of edits while it is open. Ctrl Z undoes the last edit and Ctrl Shift Z or Ctrl Y redoes it (⌘ Z and ⌘ Shift Z on macOS). The history covers every change to the request: what you type, the method, the checkboxes, adding, removing and sorting rows, and switching the body or auth type.

  • Typing in one field is one step until you pause for a second or move to another field, so undo removes what you typed in one go, not letter by letter.
  • In the URL, the cells of the tables and the Auth fields, and anywhere outside a text field (after clicking a checkbox or a button), the keys use the tab's history.
  • In the body, script and Docs editors, the keys undo the editor's own typing, keeping the cursor where it was. What you typed there is also in the tab's history, so you can undo it from any other field.
  • The right-click menu's Undo and Redo do the same as the keys where you open it: the tab's history in the URL, the tables and the Auth fields, the editor's own in the body, script and Docs editors. They are disabled when there is nothing to undo or redo.
  • Undoing back to what was last saved removes the unsaved dot. The history is lost when the tab is closed.

Found a mistake? Edit this page on GitHub or open an issue.

↑↓to move ↵to open /or Ctrl Kto search from any page