Filter Data Of API
Can I filter the data that is coming from a REST API? Can I get a specific JSON object from an array that is being fetched by an API call? and can you show me how with images?
Hey Abd Sab,
Yes this is possible, you can't change the incoming JSON but you can define what data you want to retrieve. There are a few steps:
- Create a JSON_Structure file with the JSON you get from the API:
- Create a import mapping, select the JSON Structure:
- Now select the values you want to use in your app, click ok, and connect the data to your entitiy:
This should do the trick, for a better overview how to create imports I recommend to follow this course: https://academy.mendix.com/link/paths/44/Importing-and-Exporting-Your-Data
- You can import all data with REST call. You will get list of objects.
- In the microflow you can filter the objects as per your condition
- Then return the filtered list.
We need to apply custom logic to filter the data.
- step 1 : create JSON/XML structure
- step 2 create import mapping do a map automatically to get the domain model in pace[if you dont have domain model for this in place] its easy and saves time and accurate.
- step 3 im the microflow call rest service use import mapping as the import mapping is applied you get a list of objects
- once you have the list you can use filter objects activity to filter the objects from it.
- return the filtered list
Rene van Hofwegen