In this blog, we’ll cover how to implement an UPDATE API in Mendix. An UPDATE API is used to modify existing records in the database based on specific parameters provided in the request.
First create the Mendix application in any version. Here, I am using 9.24.5
-> Open Mendix studio pro
-> Create new app
-> Select Blank web app
Go to MX Studio Pro and create an entity & give any name like “Book” & add your data.

Go to MX Studio Pro create a folder UPDATEAPI -> right click on it-> click on other->Published Rest Service & give the name PRS_UPDATEAPI.

Now go to PRS_UPDATEAPI-> add resources & give any name(UpdateApi).

Go to UPDATEAPI folder -> right click-> other->Click on Message Definition & give any name(MD_Book).

Open MD_Book(Message Definition) -> Click Add->Select your Book Entity & Check All attribute and click ok.

Go to again MD_Book(Message Definition) -> Select Book -> Click on Generate mappin to generate the import mapping and select only import mapping for this tutorial & click ok.

Double click on the Book(inside IMP_Book) & follow the image.

Go to PRS_UPDATEAPI-> Add New operations for ‘UpdateApi’-> Select PATCH Method & in the microflow create a new microflow(UpdateBookData).

Open your PRS_UpdateBookData microflow-> take a parameter of Book entity->in the Data type select Object & take another one string type(BookName).


- Take a retrieve activity -> select yout Book entity -> in the range select First -> in the Xpath pass this [BookName=$BookName].

2. Take a decision & check the condition $Book_Found!=empty.

3. If condition is true Change the object($Book_Found) with $Book/BookName for BookName and $Book/Price for Price & if condition is false show the message BookName not found.


Lastly, 1) Go to PRS_UPDATETEAPI -> Open your Patch/UpdateApi -> add one Query parameter string type -> in the microflow parameter select BookName.

2) Add one another Path parameter Object type -> in the microflow parameter select Book and in the import mapping select IMP_Book.

Now run the application & test it.

{
"BookName": "Java",
"Price": 3000
}

Conclusion:
I hope this article has helped you understand How to Implement UPDATE API in Mendix.
Thanks for reading this! See you in the next blog post.