Making API Calls with the REST Client Object in Astera
Last updated
Last updated
© Copyright 2023, Astera Software
To make an API call in Astera, A REST Client object, along with its REST Connection, needs to be configured.
First, drag and drop a REST Connection object from the Toolbox and configure it in the dataflow. Alternatively, you can use a REST Connection object from a shared action within the scope of the project you’re working with. The connection object contains the Base URL, authentication details, and shared parameters for the API endpoint.
You can learn all about the configuration and usage of the REST Connection object here.
Next, let’s configure the REST Client object.
First, drag and drop the REST Client object from the Toolbox onto the dataflow.
Right-click on the REST Client object’s header and select Properties.
The REST Client screen will now open. Here you will have to specify the following:
Shared Connection: Establish your REST Client’s connection from this drop-down that lists all shared connections from within the flow as well as from the project.
HTTP Method: The HTTP request verb defines the operation you want to make on the API resource.
Resource: the resource of the API from which you want to make a request. This will be appended after the Base URL from the selected shared connection to form the complete endpoint. Any URL or path parameters must be included in the resource text enclosed in curly brackets, {}.
Content-Type: This is the content-type header for the request payload which is defaulted to application/JSON type. The actual request payload layout can be defined in the input layout screen.
Note: For an unsupported type, a relevant pop-up notification will appear on-screen.
Click Next. A Parameters screen will appear. Here you will have to specify the following:
Override Inherited Parameter: Check this to override any parameters previously defined in the shared connection.
Name: The name of your parameter.
Parameter Location: The parameter type such as Query, URI, and Header. In this example, we are using a Query parameter.
Data Type: Specify the data type of your parameter
Default Value: The parameter’s value for which you want to make a request.
Note: Any values mapped to the input node of the object will take preference.
Click Next. A REST Client Output Layout screen will now open. Here we will select the Generate Layout by Running Request to build the response layout. Then click OK.
Note: Prior to this screen, there will be an additional screen to configure a REST Client input layout for the following methods: POST, PUT, and PATCH.
Once done, click Next, and you will be led to the Pagination Options screen.
Here, you can select the type of pagination that has been specified by the API providers. Astera offers the following pagination types.
When done, click Next, and you will be taken to the Service Options screen.
Ignore HTTP Status Codes: Selecting this option will show the results for responses other than 2xx in the flow, which are otherwise considered an error.
Continue on Retry Failure: Checking this option will let the program continue if there is a failure.
Use Parallelism: Check this option to send requests in parallel.
Include Content as String: Adds a field for serialized content text in the Response-Info output node.
Include Response Headers: Adds all response headers as a collection in the Response-Info output node.
Include Raw Bytes: Adds a field for content in the form of raw bytes in the Response-Info output node
Click Next, and the Config Parameters screen will appear.
Config Parameters can enable the deployment of flows by eliminating hardcoded values and provide a dynamic way of changing multiple configurations with a simple value change.
Click OK, and the REST Client object will be configured.
Now, right-click on the REST Client object’s header, and select Preview Output.
Your request has been executed successfully, as you can see that HTTPStatusCode is 200 which means that the REST Client has successfully carried out the GET request for the provided status.
This concludes our discussion on making API calls with the REST Client object in Astera.