API Testing
Moving on to the next use of dynamic cli you can also send requests to an API and receive responses. There are three HTTP methods you can use as of now which are:
- GET
- POST
- DELETE
Let’s see how to use them one by one, for this tutorial I am going to use reqres.in which is a platform to make sample AJAX requests.
Also once you successfully get a response you can store in your local drive.
GET Method
To perform the GET HTTP method enter the following command to your terminal
dynamic -GET
After you press enter on your terminal it will ask you to enter the URL to make the request after that you will need to enter headers if your request needs headers you can add them then it will get the response and present to you in JSON format after that you will be asked if you want to save results if you press ‘Y’ then enter the file name you want to store your results in and press enter.
POST Method
To perform the POST HTTP method enter the following command to your terminal
dynamic -POST
In the POST method we send the payload(data) there are two ways using which you can send data in dynamic-cli. First, you will be asked to enter the URL then you can add headers then you will be asked if you want to send payload data or not if you press ‘Y’ you will be prompted with two choices which are
Sending Payload from terminal
If you choose first then you can send data from the terminal you need to specify data in key:value format just like we specify in the curl request.
After that, you can save the response.
Sending Payload from JSON file
If you choose option two you can send data from the JSON input file. You need to specify the name of the file and you will get the JSON response which you can save.
DELETE Method
To perform the DELETE HTTP method enter the following command to your terminal
dynamic -DELETE
Same as other HTTP methods first you will be asked to enter the URL after that headers if the deletion operation is successful you will have the response with HTTP code 204 which represents no content.
Introduction to Dynamic CLI in Python
In this article, we will see an introduction to Dynamic CLI in Python.