# Call REST Endpoint

The **CallRESTEndpoint** function allows you to call REST web services. Simply drag it onto the design canvas and configure the properties required by the service you want to call.

***

## Properties <a href="#properties" id="properties"></a>

### Authentication <a href="#authentication" id="authentication"></a>

The authentication properties are needed when authentication is required by the web service being called.

**Type**

The type of authentication required by the server of the web service that is being called.

Options:

* **Anonymous**
* **Basic**
* **Digest**
* **Windows**

The **Type** you select will determine which authentication properties will be available to complete. 'Anonymous' will require no additional properties.

#### **Basic**:

The following properties are available when the **Type** is 'Basic'.

* **Username**: The username to authenticate against.
* **Password**: The password to authenticate against.

#### **Digest**:

The following properties are available when the **Type** is 'Digest'.

* **Username**: The username to authenticate against.
* **Password**: The password to authenticate against.
* **Domain**: The domain to authenticate the user against.

#### **Windows**:

The following properties are available when the **Type** is 'Windows'.

* **Use default credentials**: When checked, the credentials of the currently logged in Windows user will be used. When not checked, the Domain, Username, and Password properties will display to specify custom Windows credentials.

**Note:** Successful Windows authentication requires a Windows user and security for the site defined in Internet Information Server (IIS).

***

### Request <a href="#request" id="request"></a>

**URL**

The base URL to use for the service request. This excludes any parameter-specific information that are sent with the request. A valid example for this field could look like this:

`http://localhost:8022/Service/ExecuteService`

**Method**

HTTP Method type to use for the request.

Options: [learn more](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods)

* **GET**
* **POST**
* **PUT**
* **DELETE**
* **HEAD**
* **PATCH**
* **OPTIONS**

**Query String**

A list of parameters to use in order to build up the query string. A query string with a format similar to the following will be generated (note that parameters have not been URL encoded to improve readability):

`origin=CapeTown&destination=Johannesburg&sensor=false&alternatives=true`

**Headers**

Arguments and data are commonly transferred using the headers of a call. You can add data to the headers if the web service requires this.

**Body Format**

The [Body](#body) of a request needs to be in the format that the web service understands.

Options:

* Text
* Xml
* Json
* Stream
* URL encoded content
* Multipart encoded content

#### **Text, Xml, Json**:

The following properties are available when the **Body format** is 'Text', 'Xml', or 'Json'.

* **Body**: The payload of your web service call in the format specified by the [Body format](#body-format) property. If you pass data in the body, you cannot use the GET [method](#method), but need to use POST instead.

#### **Stream**:

The following properties are available when the **Body format** is 'Stream'.

* **Stream from file**: The file path whose contents will be sent in the body of the request.
* **File path**: The file path whose contents will be sent in the body of the request.

<figure><img src="https://3338214469-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1nxDeDH8GVCXb0XelqGm%2Fuploads%2Fgit-blob-b22f80486d9ebc73c0e000775a05ef147a5060c9%2Fmultipart.png?alt=media" alt=""><figcaption></figcaption></figure>

**When using a Binary file:**

* Binary content is accepted (see the **Value** field in the 'myfile' example above)
* The File Name **must** be specified.

**When using a Base64 file:**

* A string value is accepted (see the **Value** field in the 'somedata' example above)
* The File Name must **not** be specified.

If you are not sure which **Body format** to use, the standard and most likely value is 'Text'. The service that you are calling should have API documentation that will give an indication of the required format. If no API documentation exists, then the developers of the service should be able to assist in identifying the correct value.

***

### Request Signing (Certificate) <a href="#request-signing" id="request-signing"></a>

**Sign with Certificate**

Specifies whether the client should expose a certificate with which to sign requests.

{% hint style="info" %}
**Certificate**: The following properties are required when **Sign with certificate** is selected.

* **Certificate path**: The certificate to use to sign requests.
* **Certificate password**: The certificate password.
  {% endhint %}

### Request Signing (OAuth) <a href="#request-signing-oauth" id="request-signing-oauth"></a>

**Sign Request**

Specifies whether the request should be signed using the OAuth authentication standard.

**Encryption Key**

Only available when **Sign request** is selected. The key used to encrypt the request when signing.

***

### Response <a href="#response" id="response"></a>

This section allows you to configure the structure of the data that is being returned from the web service.

The supported return formats are JSON, XML, or a plain string.

**Output Type**

The data type of the response. The List option indicates whether the response should be interpreted as a list of values. The List option requires you to use JSON or XML for the [Body format](#body-format).

If you create a **Type** and you have formatted your response accordingly, you can point the Output type field at your user-defined type. After the service has executed, Linx will map the return result to the specified structure. Any field that is specified in the return structure that is not present in the response will be ignored.

**List Data Type**

This option is only visible if the [Output type](#output-type) is set to 'List'. To access this property, click on the data type editor icon displayed next to the 'List' option (after you selected it).

Indicates the data type for the items in the list.

***

### Settings <a href="#settings" id="settings"></a>

**Handle All Status Codes**

Check this property to handle success and error responses.

When checked, it will display 2 execution paths in the design canvas – “Success” and “Error”.

<div align="left"><figure><img src="https://3338214469-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1nxDeDH8GVCXb0XelqGm%2Fuploads%2Fgit-blob-685613cbe6b0753743f45b07c44fa639f1e6623f%2Fallstatuscodes.png?alt=media" alt="allstatuscodes"><figcaption></figcaption></figure></div>

Successful requests (response status code 200-299) will go into the “Success” execution path, while all other responses will go into the “Error” execution path.

{% hint style="info" %}
**Note**: Invalid requests (e.g., trying to connect to an invalid address) will still throw an exception (and not go into the “Error” execution path). The “Error” execution path is only there to handle invalid responses.
{% endhint %}

**Allow Untrusted Certificates**

Select 'True' to allow connections to sites that make use of untrusted (e.g., self-signed) certificates.

**Timeout**

The timeout value for the web service call.

**Max Response Content Size**

The maximum amount of bytes response content can contain.

***

### Web Proxy <a href="#web-proxy" id="web-proxy"></a>

These settings are applicable only if you or the server you're contacting are using a proxy server.

**Proxy Name**

The IP address or URL of your proxy server.

**Port**

The web service call is commonly performed over port 80, but you can change that if you have configured the service or proxy to use a different port.

**Bypass on Local**

While you are developing the function you may have a different setup from the live environment. When this property is checked, the proxy setup is ignored for your local machine.

***

## Links

* [Wikipedia: Representation state transfer (REST)](http://en.wikipedia.org/wiki/Representational_state_transfer)
* [Code Project: Everything About REST Web Services - What and How](http://www.codeproject.com/Articles/21174/Everything-About-REST-Web-Services-What-and-How-Pa)
* [IBM developerWorks: RESTful Web services - The basics](http://www.ibm.com/developerworks/webservices/library/ws-restful/)
* [Consuming REST APIs](https://community.linx.software/community/t/consuming-rest-apis/482)
* [Tutorial: Consuming REST APIs](https://community.linx.software/community/t/tutorial-consuming-rest-apis/484)


---

# 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://docs.linx.software/reference/plugins/rest/content/callrestendpoint.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.
