# HTTP replies

> Keep the body of a Generic HTTP GET or POST in a position variable and show it on a button.

A Generic HTTP **GET** or **POST** can keep the reply in a position variable. The button can show that variable, and any other control in the position can read it.

**PUT**, **PATCH**, and **DELETE** send the request and do not store the body.

<callout color="gray" title="Note">
  Generic HTTP is only the example on this page. Other modules can store what an action gets back, too. Some actions have their own field for picking a position variable, like the HTTP actions here. Actions from modules built on Module API 2.2 or later can return a result, and show a **Store result** field instead. It can write to a position variable or to one of the button's own variables. Generic SNMP's **Get OID value** is one of these. Which actions can store a value depends on the module.
</callout>

## Before you begin

- A Generic HTTP connection. Set **Base URL** on the connection when every request starts from the same address.
- A position variable to store the reply in. Create it on the position's **Configuration** tab, under **Position Variables**, with the type **String**. See [Use variables in controls and expressions](/docs/buttons/v1.10/variables/use-variables).

## Keep the reply

**GET** and **POST** both end with two fields:

- **JSON Response Data Variable** lists the position variables. Pick one. If the list is empty, create the variable first. The field cannot point at a button variable.
- **JSON Stringify Result** is checked by default. The variable then receives the reply as text. Clear it to parse the body as JSON. If the body is not JSON, the text is stored anyway.

The address field is **URI** when the connection has a **Base URL**, and **URL** when it does not. A value that already starts with `http` is requested as written, and the base URL is not added in front of it.

This example asks a rundown server for the current segment and shows the answer on the button.

1. Create a position variable named `segment`, type **String**.
2. On the button's **Actions** tab, add the connection's **GET** action to **Press**.
3. Enter the path in **URI**. With a base URL of the rundown server, that is `segment`.
4. In **JSON Response Data Variable**, select `segment`. Leave **JSON Stringify Result** checked when the reply is text.
5. On the **Design** tab, set the button text to `$(position.state.segment)`.
6. Select **Apply**.

![The inspector for a button named Get segment with a GET action from the Rundown server connection. URI is segment, JSON Response Data Variable is set to the position variable segment, and the button preview shows SEGMENT above Weather.](https://bitfocus.io/api/docs-media/file/http-response-variable.png?prefix=docs-media)

Press the button. The reply is written to `segment` when the request succeeds. A failed request leaves the variable as it was. Every control in the position that uses `$(position.state.segment)` updates together.

**POST** uses the same two fields. It also has **Body** and **Content Type**. For `application/json`, the body has to be valid JSON or the request is not sent.

In a workflow or a cue list, **JSON Response Data Variable** shows `Setting Custom Variables from actions are not supported.` The reply can be stored from a button on a position, including a button in a shared section that is mounted in a position.

## Where to go next

- [Button actions](/docs/buttons/v1.10/positions/button-actions)
- [Understand variable scope](/docs/buttons/v1.10/variables/understand-variable-scope)
