# REST Client

## <img src="/files/sfl98v65cywptYNkt2A2" alt="" data-size="line"> REST Client

### Description <a href="#description" id="description"></a>

The REST Client transform enables you to consume RESTfull services. Representational State Transfer (REST) is a key design idiom that embraces a stateless client-server architecture in which the web services are viewed as resources and can be identified by their URLs.

The REST client transform can use a pre-defined [REST connection](/data-shaper-1.21/knowing-the-data-shaper-designer/index-2/rest-connection.md) or use full URLs directly.\
When using a REST connection, the URL (hard-coded or accepted from a field) will be considered a path relative to the base URL defined in the REST connection. Header values that are specified in the `Headers` tab of the transform will overwrite any headers with the same name that were defined in the REST connection.

When used without a REST connection, the full URL needs to be specified.

### Example <a href="#example" id="example"></a>

The REST client Transform returns a "result" field (can change the name), and the field is often used in the next transform. For example, it can be read in by a JSON input transform that extracts the fields specified on the Fields tab.

| Hop Engine | <sup>✓</sup> |
| ---------- | ------------ |
| Spark      | ?            |
| Flink      | ?            |
| Dataflow   | ?            |

### Options

#### General Tab

The General tab is where you enter basic connection information for accessing a resource.

| Option                                 | Description                                                                                                                                                                                     |
| -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Transform name                         | Name of this transform as it appears in the pipeline workspace                                                                                                                                  |
| REST Connection                        | The (optional) [REST connection](/data-shaper-1.21/knowing-the-data-shaper-designer/index-2/rest-connection.md) to use for the base URL and authentication/authorization header name and value. |
| URL                                    | Indicates the path to a resource                                                                                                                                                                |
| Accept URL from field                  | Designates the path to a resource is defined from a field                                                                                                                                       |
| URL field name                         | Indicates the field from which the path to a resource is defined                                                                                                                                |
| HTTP method                            | Indicates how the transform interacts with a resource---options are either GET, PUT, DELETE, POST, HEAD, or OPTIONS                                                                             |
| Get Method from field                  | Designates the GET method is defined from a field                                                                                                                                               |
| Method fieldname                       | Indicates the field from which the GET method is defined                                                                                                                                        |
| Body field                             | Contains the request body for POST, PUT, and DELETE methods. Body field only accepts a previous field, not a hard coded value.                                                                  |
| Application type                       | Designates what type of application a resource is---options are either TEXT PLAIN, XML, JSON, OCTET STREAM, XHTML, FORM URLENCODED, ATOM XML, SVG XML, or TEXT XML                              |
| Connection timeout                     | Indicates the timeout until a connection is established (milliseconds)                                                                                                                          |
| Read timeout                           | Indicates the timeout for waiting for reading data (milliseconds)                                                                                                                               |
| Result fieldname                       | Designates the name of the result output field                                                                                                                                                  |
| HTTP status code fieldname             | Designates the name of the HTTP status code field                                                                                                                                               |
| Response time (milliseconds) fieldname | Designates the name of the response time field                                                                                                                                                  |

#### Authentication Tab

If necessary, enter authentication details for a resource in the Authentication tab.

{% hint style="info" %}
Tip: Hop allows using NULL parameters/variables for both the HTTP Login and HTTP Password.
{% endhint %}

| Option        | Description                                                                                                                                                                         |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| HTTP Login    | Indicates the username required to access a resource                                                                                                                                |
| HTTP Password | Indicates the password associated with the provided HTTP Login username                                                                                                             |
| Preemptive    | Option to send the authentication credentials before a server gives an unauthorized response. Currently always true, due to [bug #4196](https://github.com/apache/hop/issues/4196). |
| Proxy Host    | Indicates the name of a proxy host                                                                                                                                                  |
| Proxy Port    | Indicates the port number of a proxy host                                                                                                                                           |

#### SSL Tab

The SSL tab is where you provide authentication details for accessing a resource that requires SSL certificate authentication.

| Option              | Description                                                         |
| ------------------- | ------------------------------------------------------------------- |
| Truststore file     | Indicates the location of a truststore file                         |
| Truststore password | Indicates the password associated with the provided truststore file |

#### Headers Tab

The Headers tab enables you to define the content of any HTTP headers using an existing field. Populate the list of fields by clicking the Get fields button.

{% hint style="info" %}
Tip: To figure out what Headers are required, you can use Postman and remove as many headers as possible for the Request to still work. You should not need to use the Headers with value “\<calculated when request is sent>” in Postman. You do not need to manually add an Authorization header if you used the Authentication tab.
{% endhint %}

| Option | Description                                                                                                                   |
| ------ | ----------------------------------------------------------------------------------------------------------------------------- |
| Field  | The field from incoming Hop stream that contains the header information. Add the header value field name to the Field column. |
| Name   | The name of the outgoing Hop field from this transform. Add the header key field name to the Name column.                     |

#### Parameters Tab

The Parameters tab enables you to define parameter values for POST, PUT, and DELETE requests. GET parameters should be part of the URL directly.

| Option    | Description                                                                |
| --------- | -------------------------------------------------------------------------- |
| Parameter | The field from incoming Hop stream that contains the parameter information |
| Parameter | The name of the outgoing Hop field from this transform                     |

#### Matrix Parameters tab

Use the Matrix Parameters tab to define matrix parameter values for POST, PUT, DELETE, and PATCH requests.

| Option    | Description                                                                           |
| --------- | ------------------------------------------------------------------------------------- |
| Parameter | The field from the incoming Hop stream that contains the matrix parameter information |
| Parameter | The name of the outgoing Hop field from this transform                                |


---

# 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.primeur.com/data-shaper-1.21/knowing-the-data-shaper-designer/pipelines/transforms/rest.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.
