Mendix API integration problems

0
Hey everyone!   I just finished building my app and developed a .NET API alongside it, complete with CRUD operations for all the entities I'm using. Now, I'm trying to figure out the best way to connect my app to this API. The app is designed to have responsive navigation and also supports an offline tablet mode. My entities are persistable, but I’m feeling a bit stuck on how to properly connect them to the external API.   Here are my questions:   Should I link every request from the microflow directly to each action button? How can I map a JSON structure to an object that doesn’t exist yet? Should I first create it in the database, then retrieve it, and only then run a PUT microflow? Do I need two different JSON structures if I want to retrieve all entities (including wrapping the result in [ ] for an array), or can I use a single object structure? Are there any in-depth tutorials that cover the entire integration process? I’m looking for guidance on everything from defining JSON structures to mapping them to persistable entities, as well as how to effectively use microflows and where to call them.   Thanks in advance for your help and for contributing to the Mendix community!
asked
1 answers
1

Hi Alix,

 

In the learning path "Importing and Exporting Your Data", you can learn more about integrating with your Mendix application: https://academy.mendix.com/link/modules/138/lectures/5198/Learning-Objectives

 

If you have persisted data in the API, you have roughly 2 choices:

- either synchronize the data of the API to your Mendix app as persistant data (periodically)

- or use non-persistant entities in Mendix and retrieving/manipulating all data via REST Consume / JSON-structures / Mapping activities in your Microflows

 

If you want to use the offline functionality of Mendix apps, you probably need to do the first.

 

Mendix is a bit restricted when it comes to data structures, you cannot mix objects of different entities in one list. You could do something like shown below, but I personally would prefer to retrieve per entity.

{
  "cars": [{"make":"VW", "wheels": 4}],
  "planes": [{}]
}

 

In Mendix, it's easy to first create all JSON structures and then create import mappings based on those structures. If you click "Map automatically", Mendix will create Non-Persistent entities with the same attributes.

 

Hopefully this helps in the right direction.

Good luck!

Johan

answered