API Tool
The API Tool allows users to interact with web APIs by configuring the HTTP method, URL, headers, and body of the request.
Steps to Use the API Tool
Step 1: Access the Tool
- Click on
Add User Step
. - From the available options, select the
API
Tool.
Step 2: Input the Method
You need to specify the HTTP method for the API request. Input one of the following HTTP methods: GET
, POST
, PUT
, HEAD
, PATCH
, DELETE
, OPTIONS
.
Step 3: Input the URL
You need to provide the URL of the API endpoint. You have two options for entering the URL:
- Manual Entry: Type the URL of the API endpoint directly into the input field.
- User Input Variable: Use a user input variable to dynamically provide the URL. To use input variables within your URL, use the syntax
{{variable_name}}
to access the value of an input variable. For example, if there is an input parameter named “apiURL”, you can access its value using{{apiURL}}
.
Step 4: Input the Headers
You need to provide the headers for the API request. Input key-value pairs for each header. For example:
- Key: Content-Type
- Value: application/json
Step 5: Input the Body
You need to provide the body of the API request, if applicable. You have two options for entering the body:
- Manual Entry: Type the body of the API request directly into the input field.
- User Input Variable: Use a user input variable to dynamically provide the body. To use input variables within your body, use the syntax
{{variable_name}}
to access the value of an input variable. For example, if there is an input parameter named “requestBody”, you can access its value using{{requestBody}}
.
Step 6: Configure Guardrails Validators (Optional)
You can set up guardrails validators to ensure the API request and response meet certain criteria. Set up validators based on your specific needs. This may include rules for response status codes, data validation, or other criteria.
Step 7: Execute the API Request
Once you have configured the method, URL, headers, and body, initiate the API request:
- Run the tool: Click the
Run
button to start the API request process. - Results: The tool will process your request and send the API request based on the provided inputs.
Step 8: View the Output
The response from the API will be displayed in the results section. The results will be presented in a structured format, often in JSON or plain text, depending on the nature of the response.
Step 9: Utilize the Results
You can now use the API response for further processing, analysis, or integration into your application.
Tips for Effective Use
- Correct URLs: Ensure the API endpoint URL is correct and publicly accessible to avoid errors during the request process.
- Appropriate Methods: Use the correct HTTP method that matches the API endpoint's expected operation.
- Effective Headers and Body: Ensure the headers and body are formatted correctly based on the API's requirements.
- Review Results: Carefully review the API response to ensure it meets your requirements.
If you have any questions or need further assistance, please contact the helpdesk([email protected]).