Filter Data Of API

1
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?  
asked
4 answers
0

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:

  1. Create a JSON_Structure file with the JSON you get from the API:

 

  1. Create a import mapping, select the JSON Structure:

 

  1. 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 

answered
5
  1. You can import all data with REST call. You will get list of objects.
  2. In the microflow you can filter the objects as per your condition 
  3. Then return the filtered list.

    We need to apply custom logic to filter the data.
answered
1
  • 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
answered
0

The best way is:

  1. either send a more restrictive request so that you get a filtered list back from you API
  2. If 1 isn't possible: 
    1. Map the incomming JSON respons to Mendix object (which is the default anyway)
    2. Filter the resulting object list

 

Some docs:

https://docs.mendix.com/refguide/json-structures/ 

https://docs.mendix.com/refguide/import-mappings/ 

answered