Dynamic REST Calls

0
Hello everyone, In our use case, an administration shell (AAS) is interacted with via REST calls. The AAS is dynamically filled with a variable number of assets, which are always structured according to the same standard, but not always in the same order. In order to be able to query or write individual values, the paths of the existing assets must first be read. Each asset consists of several submodels in which the values are grouped. A query for the entire arrangement with three exemplary assets is attached. They are listed as array elements, whereby new assets can be added at the end and those that are deleted simply disappear from the array. It should also be noted that in this query, the elements of the submodels in which the searched paths are present as ‘value’ under ‘keys’ are also created in array form. It must be possible to query each individual path from each individual asset. In our previous attempts, we encountered the problems that, on the one hand, there is no fixed JSON structure that can be expected from a get call and, on the other hand, several paths cannot be read out due to the same keys of the assets and submodels. Is there a solution to these two problems on the Mendix side without having to adapt the AAS?
asked
1 answers
0

I think what you are asking here is a complex import mapping setup. I don't understand the full scenario, but here are some possibilities:

> In order to be able to query or write individual values, the paths of the existing assets must first be read.

This sounds like solve-able by using "find by key" approach in import mapping. You can also use "find by microflow" where you can handle finding the path on your own. This is the most powerful way available in import mapping.

 

> They are listed as array elements, whereby new assets can be added at the end and those that are deleted simply disappear from the array. 

The "find by key" approach would create object by default when the key is not found.

To delete an object during import mapping is not possible. You could introduce timestamp to indicate when was the last time this object being updated. With this information, you can clean the objects afterward.

 

> on the one hand, there is no fixed JSON structure that can be expected from a get call

This contradicts with the earlier statement, `which are always structured according to the same standard`. In the case "structure is not fixed but predictable", you can simply receive it as a string in microflow, then handle the import mapping as the next activity depending on the type of payload. However, if the structure is unpredictable, the only option is to handle it yourself.

 

Hopefully this information helps.

answered