# HTTP-request step

![](https://3071851461-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4Nnmtk9_gFGWOddsf6%2F-MZbFLFW2URQRwndL3fu%2F-MZbIHq0dUUVtZC5W2wR%2Fstep.png?alt=media\&token=1aec8107-08e5-4242-9b4b-90e4a18e2d30)

**HTTP-request step** allows you to interact with HTTP & REST APIs

![](https://3071851461-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4Nnmtk9_gFGWOddsf6%2F-MZbIMjjI7D082cEdsJc%2F-MZbKD-qJyk0q-eq7QKc%2Fui.png?alt=media\&token=1a8cc139-00c7-40c0-a094-c52b0a6ffc70)

### **1. Set request method, paste URL and add parameters**

![](https://3071851461-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M4Nnmtk9_gFGWOddsf6%2F-MZbIMjjI7D082cEdsJc%2F-MZbK_kHCcOtifa9XRc7%2Fmethod.png?alt=media\&token=453ca0d4-cac2-4385-ba05-67ba67622ac3)

You can add parameters both in URL input, like `https://api.directual.com?param1=aaaa&param2={{field}}` or using Parameters tab. Feel free to add `{{fields}}` using [template system](https://readme.directual.com/template-system/basics-of-template-system).

{% hint style="info" %}
Remember that if parameter value contains characters like " ", "`+`", "`–`", wrap it in `{{#encodeURIComponent}}` *parameter value* `{{/encodeURIComponent}}`
{% endhint %}

### 2. **Optional: Add headers and Body**

You can add headers and body  for your request, using [template system](https://readme.directual.com/template-system/basics-of-template-system).

Note that choosing the body type (json, x-www-form-urlencoded) you add specific headers.

{% hint style="info" %}
If your JSON-body includes strings with special characters (like `"`), wrap it with `{{#escape}}wrapped "text"{{/escape}}`
{% endhint %}

### **3. Optional: Setup auth**

Choose the proper auth (or no one) and the authorisation header will be automatically generated when you send the request.

### 4. Optional: Add custom options

* **Save API response** to the field. Field should be type of json or string. It's easy to parse the response using [JSON-step](https://readme.directual.com/scenarios/editing-scenarios/action-steps/json-step).
* **Ignore HTTP-errors**. If this option is turned off, scenario will stop executing and call [Catch error step](https://readme.directual.com/scenarios/editing-scenarios/system-steps/catch-error-step), if any. If it is on, the scenario will continue executing.
* **Enable retry**. Retry the request in case of error-code.
* **Retry non idempotent requests** (e.g. POST). have a look at a nice explanation [what is non idempotent requests](https://www.restapitutorial.com/lessons/idempotency.html).
* **Retry count**. How many times retry connecting.
* **Read timeout**, ms. Max 180000 — 180 sec.
* **Connect timeout**, ms. Max 5000 — 5 sec.
* **Certificates**. Add (if needed) .PEM text and key
* **Proxy**. Add (if needed) proxy. You may [have one here](https://proxy-seller.com/?partner=HDL8XUZ8FQTSNU) (choose IPv4).

### 5. Sending files

Set the content type to `multipart/form-data`

![](https://3071851461-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4Nnmtk9_gFGWOddsf6%2Fuploads%2FWqY9kYGGmt8t8pk7mraP%2Fimage.png?alt=media\&token=d0606dcf-bdb5-4952-8000-62a7c79e4c41)

Body for that type of request should be the following:

![](https://3071851461-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M4Nnmtk9_gFGWOddsf6%2Fuploads%2FvdTkSv79DM7HAO0c1zO1%2Fimage.png?alt=media\&token=121a3ccf-6c7c-4d5a-8bed-463035a83e77)

```javascript
{
	"file": "{{ContextVar.fileUrl}}", // URL of your file
	"__files_fields__":["file"]
}
```
