Building Dynamic Asset
Last updated
Last updated
Let's click on the "Dynamic API" button and start with Dynamic Asset Creation.
After clicking on the "Dynamic API" button you'll be redirected to the below page.
We have two methods for building APIs:
Let's take a closer look at each option separately.
By default, Basic mode will be selected. Let's take a look at each field mentioned in the above image.
API Name
Give a Proper API name from which you can identify its use case.
Context Path
Give Context Path which you want to be present in the generated API URL.
Mode
Because we're investigating API creation using the basic mode, keep it chosen.
Request and Response
In this part, your API will create data. There are two things you need to consider here:
Number of Rows: Specify the number of rows you wish to generate.
Data Fields: Include and choose the type of information you want from the dropdown. For instance, you can select Firstname, CompanyName, Country, and more. Please make sure to provide the right names for these fields.
For example, check the below screenshot.
After you've completed entering all the information, press the "Save" button to create the data.
You'll find the generated data in the "data preview" tab on the right panel.
The ID field will be automatically created for performing various actions such as POST, DELETE, and more.
Once data generation is done and no more modification is required, you can click on the "Generate API" button to generate your Dynamic APIs.
After clicking on the Generate API button, You'll see a couple of new information below like the URL.
URL consists of our endpoint + unique identifier + your given context path
You have the option to utilize that URL for accessing dynamic APIs anywhere outside of qyrus as well as other functionalities it offers.
You can click on the "Send" button to hit the Get method of that API and see the result.
As shown in the above result, you'll find a couple of things such as,
Status Code
Response Time
Response Data
To utilize the POST method, you need to consider the following points.
Provide the mentioned header for every POST request made with dynamic APIs Content-Type: application/json
Provide Request body for post method
for the above example you can provide a request body like this
Don't provide ID as it'll be auto-generated for all records.
Give the above information and click on the "Hit" button. You'll see the below result.
In the above result, you can notice 2 things which are...
Status Code is 201 which is for newly created data in data source
ID is 31 because we already had 30 records. so the newly created record is the 31st.
To utilize the PUT Method, you need to consider the following points.
In Path Param give the ID for which you need to update the record
Provide the mentioned header for every POST request made with dynamic APIs Content-Type: application/json
Add the request Body which you need to update.
Let's continue the above example and give this request body
Give the above information and click on the "Hit" button. You'll see the below result.
In the above result, you can notice 2 things which are...
Status code is 200 which is a success response
In response to data, the Country is changed to 'Bharat' from 'India'.
To utilize the DELETE Method, you just need the ID of the record.
You can pass the ID as Path Param and hit the request it'll delete the record.
for example, Let's delete the above-created record whose ID is 31. so give 31 as the Path param and hit the request and the result should be shown as below.
Here you can notice the status code is 200 which means the record is deleted. You can verify it by hitting Get Request.
Wild Card Search
You can perform wild card searching with the help of any data. for example,
Search by Path Param using Country Name GET /shipdata-amazon/Japan
Search by Path Param using ID GET /shipdata-amazon/21
and So on...
Pagination
You can perform Pagination using Dynamic APIs. for example,
Fetch 2nd-page data where on page there should be 10 records GET /shipdata-amazon?_page=2&_limit=10
Filter
You can Filter data using Dynamic APIs. For example,
Filter data by Query Param using Company Name GET /shipdata-amazon?company=Unilogic
Sorting
You can Sort the all records as well as shown below.
Sort the data using the company name and in descending manner GET /shipdata-amazon?_sort=company&_order=desc