consume an API

I have an API endpoint namely – . API takes body input as – { "year" : "2021" } in a POST request. How can I use this API with body parameters and display the result on a page. Please provide a step wise instruction guide, I have already referred mendix documentation for how to consume REST service / how to call rest service. Please guide me how can I get the required output. API response is as following – {     "status": true,     "success": true,     "message": "",     "records": [         {             "id": 16,             "holiday_date": "2021-01-01",             "holiday_desc": "New year "         },         {             "id": 17,             "holiday_date": "2021-01-02",             "holiday_desc": "New year"         },         {             "id": 18,             "holiday_date": "2021-02-27",             "holiday_desc": "ASHA Bucha Day"         },         {             "id": 19,             "holiday_date": "2021-04-13",             "holiday_desc": "Songkran Day"         },         {             "id": 20,             "holiday_date": "2021-04-14",             "holiday_desc": "Songkran Day"         },         {             "id": 21,             "holiday_date": "2021-04-15",             "holiday_desc": "Songkran Day"         },         {             "id": 22,             "holiday_date": "2021-05-01",             "holiday_desc": "Labor Day"         },         {             "id": 25,             "holiday_date": "2021-06-03",             "holiday_desc": "Queen Suchada Birthday"         },         {             "id": 23,             "holiday_date": "2021-07-24",             "holiday_desc": "Asalha Bucha Day"         },         {             "id": 24,             "holiday_date": "2021-07-25",             "holiday_desc": "Buddhist Lent Day"         },         {             "id": 26,             "holiday_date": "2021-07-28",             "holiday_desc": "King Vajiralongkorn Birthday"         },         {             "id": 27,             "holiday_date": "2021-12-05",             "holiday_desc": "Father Day"         },         {             "id": 28,             "holiday_date": "2021-12-31",             "holiday_desc": "New Year Eve"         }     ],     "error": "" }
2 answers

First add import mapping for the response:

Since your API only accepts JSON, you should also add an export mapping even though the request is very simple:


You will get entities like this after the creating these mappings


Then create the microflow:

1: create the REQ object

2: consume REST API

for the request part, select export mapping for the entire request, then pick the export mapping you created. for the parameter, pick the REQ object you created

For the Response,  choose Apply import mapping for Response handling, and then choose the mapping you created before.

store the response in variable, type as the RESP entity, and name can be anything


Next activity, retrieve Records from the response, then add another activity, retrieve a list of holidays from Records via association. Set the holiday list as return value

Then create a page, use a listview, use the microflow you just created as datasource:


This is just a sample to show you how to implement what you need. you should also set up error handling, empty data handling in your page and microflow.


You need to choose import mapping in the response tab of call rest-activity and, you need to create import mapping and JSON structure. 
It will create a non-persistable entity for you, 
you want to save data make it a persistable entity.