DELETE
The HTTP DELETE request method deletes the specified resource.
We already know how to make basic API from the API Example Page.
This Page explains how to make a DELETE method API, delete data in the database and get a response from this DELETE API!
Add New DELETE Path (in APIs Page)
β‘οΈ Add New DELETE Path (in Server Page).
As you know, we already made API and Server.
So, we just add a NEW PATH and Add this in the Server in Autoflow
Follow the below steps!
We will make below DELETE /user/{user_id}
Then we will delete data in the database by DELETE /user/{user_id}
Before Starting, Assuming that the Clients is already connected, this page will only explain the post method.
1. Add New Path with URL Pathβ
We already made Autoflow API and Autoflow Server.
So we will use this which we made.
Then just add a new Path.
1.1 Click the Add Path button and write your Path name!β
First, we click the Add Path button. Then we will write the path name.
We select the DELETE Method.
You can write the URL path Name whatever you want to write.
1.2 API page Overviewβ
When you added a New path, We can see below the new Path.
DELETE/user/{user_id}
Also, you can make this path by OpenAPI schema on the right side!
2. Add New Path to a Server!β
Let's add new path to a Server!
As you know, we already made a Server from the API Example Page.
2.1. Click Server Page, Then Click Server Operation!β
Click Server Page, then Click Server Operation which we made it before!
2.2. Click Add API Operation, Then Click your new Path!β
Click Add API Operation, then Click your new PATH.
Now we can see the below screen.
The API has already been made and completed.
However, our goal is to send DELETE /user/{user_id}
Now we can use DELETE /user/{user_id}
3. Delete User Data using Action.β
Using DELETE /user/{user_id}
Let's delete the user data in the database!
To parse Data, we should add Autoflow Action.
3.1 Click the Add Action buttonβ
To add Action, we should click the Add Action Button.
3.2 Select Action.β
We have lots of Actions in Autoflow.
On this page, we will use Database Query Action.
Select Database
Then Select Query
3.3 How to use Database Query Action.β
This page's goal is to insert a query in the database from DELETE with URL PATH.
I will send DELETE with the request URL PATH
3.3.1 Select your Clientβ
Select the Client that you connected.
I will connect the 'MySQL' database.
If you don't know how to connect Client, Click hereπ
3.3.2 Write DELETE SQL in 'Query'β
Our goal is to insert a query in the database from the DELETE URL PATH.
Write DELETE QUERY and Select 'Write' in Type.
I only wrote DELETE FROM `account` WHERE id= ;
Because I will put Values from DELETE URL PATH.
3.3.3 Add the variable Name that you want.β
Write a variable name in the Key field.
3.3.4 Drag the Param to where you want to insert in the query.β
Let's drag the 'user_id' param to where you want to insert in the query!
3.3.5 Click String type in Paramsβ
We want to use the DELETE URL path.
So we will this variable as one of the DELETE URL path.
3.3.6 Change to Data Typeβ
Click Data Type.
3.3.7 Write Path Scope!β
We can get DELETE Request Body by request > path > user_id
.
So write the path below.
3.3.8 We are ready to DELETE Request! πβ
3.3.9 Send Database query As a Response.β
I want to DELETE the response as my database table.
So, I will Add one more action to the response.
SELECT * FROM `account`;
then the QUERY result will be DELETE Response.
4. Test DELETE Request and Responseβ
I will use POSTMAN to DELETE request with URL Path.
Before starting my user database is as below.
4.1 DELETE Request with Reqeust PATH.β
First, I will DELETE with URL PATH.
DELETEURL: http://localhost:8080/user/1
Then I got the below response. Now we can see the URL path user's data was deleted in the MySQL database.
Second, I will check the result using Action.
Then I got the below response. Now we can see the URL path user's data was deleted in the MySQL database.