Skip to main content
?

PUT

The HTTP PUT request method creates a new resource or replaces a representation of the target resource with the request payload.


We already know how to make basic API from the API Example Page.
This Page explains How to make PUT Method API, update data in the database, and Get a response from this PUT API!

Goal

Add New PUT Path (in APIs Page)

➑️ Add New PUT Path (in Server Page).

As you know, we already made API and Server.
So, we just add the NEW PATH and Add this in the Server in Autoflow
Follow the below steps!


note

We will make below PUT /user/{user_id}
Then we will update data in the database by PUT /user/{user_id} with Request Body.

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 PUT Method.

Version Location
tip

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.

PUT

/user/{user_id}

Version Location
tip

Also, you can make this path by OpenAPI schema on the right side!


2. Add a New Path to the Server!​

Let's Add a New Path to the 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!

Version Location

2.2. Click Add API Operation, Then Click your new Path!​

Click Add API Operation, then Click your new PATH.

Version Location

Now we can see the below screen.
The API has already been made and completed.
However, our goal is to send PUT /user/{user_id} with URL PATH and Request Body

Version Location
tip

Now we can use PUT /user/{user_id}


3. Delete User Data using Action.​

Using PUT /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 an action, we should click the Add Action button.

Version Location

3.2 Select Action.​

We have lots of Actions in Autoflow.
On this page, we will use Database Query Action.

Select Database

Version Location

Then Select Query

Version Location

3.3 How to use Database Query Action.​

info

This page's goal is to insert a query in the database from the PUT with URL PATH AND Request Body.
I will send PUT with Request URL PATH & Body

3.3.1 Select your Client​

Select your Client which you connected.
I will connect 'MySQL' database.

tip

If you don't know how to connect Client, Click hereπŸ”—

Version Location

3.3.2 Write UPDATE SQL in 'Query'​

Our goal is Insert Query in Database from PUT URL PATH.
Write UPDATE QUERY and Select 'Write' in Type.
I only wrote UPDATE `account` SET name = WHERE id = ;
Because I will put the values from PUT URL PATH & Request Body.

Version Location

3.3.3 Add a Variable Name.​

Write the variable name in the Key field.

Version LocationVersion Location

3.3.4 Drag the Param to where you want to Update.​

Let's drag the 'updated_id' and 'user_id' params to where you want to update!

Version Location

3.3.5 Click String type in Params​

We want to use the PUT URL Path.
So we will use this variable as one of the PUT URL Path.

Version Location

3.3.6 Change to Data Type​

Click Data Type.

Version Location

3.3.7 Write Path Scope!​

We can get PUT Request Body by request > body > new_name.
So write the path below.

Version Location

In the same way, user_id proceeds the same way.

Version Location

We can get PUT URL Path by request > path > user_id .
So write path by below.

Version Location

3.3.8 We are ready to PUT Request! πŸ‘β€‹

Version Location

3.3.9 Send a Database query as a Response.​

I want to PUT a Response in the database table.
So, I will add one more action to the response.
SELECT * FROM `account`; then the QUERY result will be PUT Response.

Version Location

4. Test PUT Request and Response​

info

I will use POSTMAN to PUT request with the URL Path & Request Body.

Before starting my user database is as below.

Version Location

4.1 PUT Request with URL Path & Request Body.​

First, I will PUT with URL Path AND Request Body.

PUT

URL: http://localhost:8080/user/2

Then I get the below response. Now we can see the URL Path user's data was updated in the MySQL database.

Version Location

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 updated in the MySQL database.

Version Location