# HTTP Request Creator

Sends an HTTP request; returns the status code, the text and the headers of the response. The request is prepared in the window opened with the **Open Creator** button on the activity. Even if the status code of the response indicates failure (e.g. 404, 500), the activity does not throw an error; the result is checked with `StatusCode`.


---

### :arrow_left:**INPUT**

| **Parameter** | **Type** | **Required** | **Description** |
|-----------|------|----------|-------------|
| `Headers` | `Dictionary<String, String>` | ❌ No     | Request headers (header name → value). Written here when the **Headers** tab in the window is saved. `{{variable}}` expressions in the values are replaced with the value of the variable at run time. |
| `QueryParameters` | `Dictionary<String, String>` | ❌ No     | Query parameters to add to the URL (name → value). Written here when the **Params** tab in the window is saved. `{{variable}}` expressions in the values are replaced. |


---

### :arrow_right:**OUTPUT**

| **Parameter** | **Type** | **Description** |
|-----------|------|-------------|
| `StatusCode` | `HttpStatusCode` | The HTTP status code of the response (e.g. `OK`, `NotFound`). |
| `TextContent` | `String` | The response body, as text. |
| `ResponseHeaders` | `Dictionary<String, String>` | The response headers. Multiple values of the same header are joined with commas. |
| `ContentHeaders` | `Dictionary<String, String>` | The headers of the response content (e.g. `Content-Type`, `Content-Length`). Multiple values are joined with commas. |


---

### Usage

At the top of the **Open Creator** window are the method (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS) and the URL field, with tabs below them.

* **Params**: query parameters. Unchecked rows are not saved.
* **Authorization**: as **Type**, select No Auth, Basic Auth (**Username** and **Password**) or Bearer Token (Token).
* **Headers**: request headers. Unchecked rows are not saved. When the `Headers` input is empty, the window opens with the headers `Content-Type: application/json`, `Accept: */*`, `Accept-Encoding: gzip, deflate, br` and `Connection: keep-alive`.
* **Body**: as **Body Type**, select None, Raw (JSON), Raw (Text) or x-www-form-urlencoded. The body is sent only in POST, PUT, PATCH and DELETE requests. For x-www-form-urlencoded, write one `name=value` per line or separated by `&`.
* **Settings**:
  * **Automatically follow redirects**: redirects are followed for 3xx responses. Default: **On**.
  * **Maximum number of redirects**: the maximum number of redirects to follow. Default: 10; if 0 is entered, 50.
  * **Encode URL automatically**: if on, the names and values of the query parameters are added URL-encoded. Default: **On**.
  * **Disable cookie jar**: if on, no cookies are used in the request. **On** for a new request.
  * **Request timeout (Miliseconds)**: the maximum time to wait for the response. If 0, the default timeout (100 seconds) applies. If the time runs out, the activity throws the error "Request Cancelled".
  * **Enable SSL certificate verification**: the activity does not use this setting.

`{{variable}}` can be written in the URL, the body, the authorization fields and the header / parameter values; at run time it is replaced with the value of the variable. If the variable does not exist or is empty, empty text is used instead.

**Send** sends the request from the window immediately and shows the response in the **Response** section; if the status code is not 200, the code and its description appear in the error area. **Cancel** stops the request being sent.

**Save** writes the request to the activity; the **Headers** and **Params** tables are transferred to the `Headers` and `QueryParameters` inputs. If a variable is bound to these inputs, the corresponding tab cannot be edited ("Editing is not allowed because the variable is set.") and the input is not changed.

If the request has never been saved in the window, the activity throws the error "Http request is required. Please create a request via designer window"; if the URL is empty, it throws the error "Url is required".