> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# HttpRequest

> The HttpRequest object — send application/x-www-form-urlencoded, text, JSON, or binary HTTP requests from a Custom activity script.

`HttpRequest` sends HTTP requests containing `application/x-www-form-urlencoded`, text, or binary data to external services.

## Properties

| Name                       | Type    | Access     | Description                                                                                         |
| :------------------------- | :------ | :--------- | :-------------------------------------------------------------------------------------------------- |
| **Url**                    | string  | Read-write | The resource URL.                                                                                   |
| **Method**                 | string  | Read-write | The request type (for example, `GET` or `POST`).                                                    |
| **AuthToken**              | string  | Read-write | Authentication token if the external service requires authentication.                               |
| **AuthScheme**             | string  | Read-write | Authentication scheme.                                                                              |
| **ThrowExceptionOnFailed** | boolean | Read-write | If `true` (default), HTTP response status codes outside 200–299 raise an exception. See note below. |
| **Timeout**                | number  | Read-write | Request timeout in minutes. Default is 1 minute.                                                    |
| **ResponseText**           | string  | Read-only  | The response body in text format.                                                                   |
| **ResponseType**           | string  | Read-only  | The content type of the response (for example, `application/json`).                                 |
| **Status**                 | number  | Read-only  | The HTTP response status code from the external service.                                            |

<Note>
  When `ThrowExceptionOnFailed` is `false`, exceptions aren't raised for 4xx/5xx responses — inspect `Status` to check the HTTP status code yourself. A response with an error code means the external service is reachable and responding. Errors related to service availability or connection failures always raise a program exception, regardless of this property — in those cases no HTTP status code is available.
</Note>

<Note>
  If `ThrowExceptionOnFailed` is `true` and the response is an error code, the transaction is interrupted and the error message appears in Skill Monitor.
</Note>

<Warning>
  The `Timeout` value can't exceed the script runtime limit (600 seconds).
</Warning>

## Methods

### SetHeader

```javascript theme={null}
void SetHeader(string name, string value);
```

Sets an additional HTTP header for the request. Call once per header.

### Send

```javascript theme={null}
void Send();
```

Sends the HTTP request.

### SetFileContent

```javascript theme={null}
void SetFileContent(DocumentExportResult documentExportResult, string mediaType?);
void SetFileContent(BinaryFile binaryFile, string mediaType?);
```

Initializes a file-based HTTP request body. The content type is detected from the file extension (for example, `application/json`, `application/pdf`). To override, pass `mediaType`.

* The first overload sends exported data (from `Document.Exports`) as a file.
* The second overload sends binary data — either a source image from when the transaction was created, or an image from a field of type **Picture**.

### SetSourceFileContent

```javascript theme={null}
void SetSourceFileContent(string mediaType?);
```

Initializes a binary-data request with the source image imported when the transaction was created. The content type is detected from the file extension. Override with `mediaType` if needed.

<Warning>
  `SetSourceFileContent` is deprecated — it only accesses the first file in a transaction. Use [`SetFileContent`](#setfilecontent) instead.
</Warning>

### SetStringContent

```javascript theme={null}
void SetStringContent(string content, ContentEncoding contentEncoding?, string mediaType?);
```

Initializes a string-based HTTP request body. Defaults to `Content-Type: application/json` and UTF-8 encoding. Override either using the optional parameters.

### SetUrlFormEncodedContent

```javascript theme={null}
void SetUrlFormEncodedContent(any content);
```

Initializes the request body from a JavaScript object and encodes it as `application/x-www-form-urlencoded`. The object should be a simple set of property/value pairs:

```javascript theme={null}
var form = {};
form.grant_type = "password";
form.scope = "openid permissions";
form.client_id = "value of client_id";
form.client_secret = "value of client_secret";
form.password = "Password";
form.username = "User Name";
request.SetUrlFormEncodedContent(form);
```

## Related topics

<CardGroup cols={3}>
  <Card title="Context" icon="braces" href="/vantage/documentation/skill-designer/process/custom-activity/context">
    Global object for transaction data, HTTP requests, and secrets.
  </Card>

  <Card title="MultipartFormDataRequest" icon="globe" href="/vantage/documentation/skill-designer/process/custom-activity/multi-part-form-data-request">
    Make multipart/form-data HTTP requests from Custom activity scripts.
  </Card>

  <Card title="BinaryFile" icon="file-binary" href="/vantage/documentation/skill-designer/process/custom-activity/binary-file">
    File data in binary format — typically the pre-preprocessing source image.
  </Card>

  <Card title="DocumentExportResult" icon="file-export" href="/vantage/documentation/skill-designer/process/custom-activity/document-export-result">
    Access exported document files (JSON, PDF, images) from a script.
  </Card>

  <Card title="ContentEncoding" icon="gear" href="/vantage/documentation/skill-designer/process/custom-activity/content-encoding">
    Encoding types available for string-based HTTP requests.
  </Card>

  <Card title="Object model" icon="diagram-project" href="/vantage/documentation/skill-designer/process/custom-activity/object-model">
    Full JavaScript object reference for Custom activity scripts.
  </Card>
</CardGroup>
