REST API - Get

This function block is designed to retrieve data from a specified REST API server using a GET request. It allows users to specify a server address and an optional data ID to fetch corresponding data.

πŸ“₯ Inputs

Enable Condition A boolean input that enables the API call when set to true.

Server Address A string input to specify the endpoint of the REST API from which data will be retrieved.

Data ID Optional string input to specify a key from the API response to extract specific data.

πŸ“€ Outputs

Status Code This output shows the HTTP status code returned by the server after the GET request.

Error This output gives any error message received from the server, if the request is unsuccessful.

Response This output contains the data returned by the server, which could be either raw text or JSON data corresponding to the specified Data ID.

πŸ•ΉοΈ Controls

Timeout (s) A text box where the user can specify the timeout duration for the server request in seconds.

🎨 Features

Conditional Execution This block runs the API call only if the enable condition is set, ensuring efficiency and control over the request process.

Dynamic Response Handling Users can receive both raw responses and specific data items from the JSON response based on the provided data ID.

πŸ“ Usage Instructions

  1. Set Enable Condition: Connect a boolean value to enable the execution of the request.

  2. Enter Server Address: Provide the REST API endpoint URL in the Server Address input.

  3. Optional Data ID: If you wish to retrieve a specific piece of data from the response, enter the corresponding key in the Data ID input.

  4. Set Timeout: Specify the timeout duration to wait for the server response in seconds.

  5. Evaluate: Run the block to execute the GET request and retrieve the data.

πŸ“Š Evaluation

Upon evaluation, this function block will perform the specified GET request and return the status code, any error message, and the response content.

πŸ’‘ Tips and Tricks

Ensuring API Accessibility

Before setting the server address, ensure that the REST API server is reachable and that the URL is correct. Use your web browser to check if the endpoint returns data.

Debugging Responses

If there's an issue with the response, check the Error output for more information. This can provide insights into what went wrong (e.g., 404 errors, server unavailability).

Handling Complex Responses

For complex JSON responses, consider using a combination of blocks such as JSON Parser or Data Type Converter to extract and manipulate data further.

πŸ› οΈ Troubleshooting

No Response Received

If you are not receiving any response, verify that the server address is correct, and check to see if the server is active and capable of handling requests.

Timeout Errors

If a timeout error occurs, consider increasing the timeout duration specified in the Timeout (s) input to allow more time for the server to respond.

Last updated