# Send HTTP request

Get page on [example.com](http://example.com)

```javascript
  HTTP.get( {
    url: "http://example.com",
    success: '/onLoading',
    error: '/onError'
    
    // if you need pass headers.
    // By default header "content-type" = 'application/json'
    // headers: { "content-type": null }
    // folow_redirects: true, // if you need folow by redirects
    // background: true - if you have timeout error
  } )

/* also you can send POST, PUT, DELETE, OPTIONS requests:
  HTTP.post( {
    url: "http://example.com",
    success: '/onLoading ',
    body: {},  // body params
    // cookies: "" // cookies
    // headers: { "content-type": null } // - if you need headers
    // folow_redirects: true, // if you need folow by redirects
  } )
*/
```

{% hint style="warning" %}
By default header "content-type" is 'application/json'. Some api may have a bug with this. Try set `headers: { "content-type": null }`
{% endhint %}

{% hint style="success" %}
You can use `GET`, `POST`, `PUT`, `DELETE`, `OPTIONS` methods.\
`Http.post`, `HTTP.put` and etc
{% endhint %}

\
\
Command `onLoading`

```javascript
// downloaded page stored on content field
Bot.sendMessage(content);

Bot.inspect(http_status);   // "200"
Bot.inspect(http_headers);  // headers from response
Bot.inspect(cookies); // it is blank for example.com
```

Command `onError`

```javascript
Bot.sendMessage("Error on downloading");

Bot.inspect(http_status);
Bot.inspect(http_headers);  // headers from response
Bot.inspect(cookies);
```

{% hint style="info" %}
Http request can be performed in background with bigger [timeout](/limitations.md).
{% endhint %}

Pass `background: true` if you need request from slow web page. Task on backgroud is more slowly but it have bigger timeout limit.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.bots.business/bjs/send-http-request.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
