Multiple objects created after calling REST service

0
Hi!  I'm creating a small program to practice with using a REST service. I'm using postcodeapi.nu. I've succesfully created a microflow, JSON structure and importmappings. Where is goes sour is when I select an object from the JSON tree that is nested. Mendix want to create a new entity for this object, and thus map it to a new object. What I am trying to do is create one entity "Address" with several attributes such a postal code, street name, house number etc. When I want to include the GEO location and map this to the entity  "Address", two objects are created. One with all the attributes mentioned before, with geo blank, and one object with all attributes blank, except for the geo information. How can I tell Mendix to store the GEO information in the same object as the other information? Thanks!
asked
2 answers
4

As far as I can tell, the postcodeapi.nu provides a nested JSON tree. This means the GEO object is inside the Address object, and thus are 2 different objects (but related). When you go and try to map this to the same object in your domainmodel, the mapping will create 2 unique instances (because they are). What you can best do, is keep the nested structure the API provides in your domainmodel as non-persistant objects, and upon interpreting the data, create the object you actually want.

answered
2

Hi Bart,

If I understand correctly, your import mapping is storing geo information in a separate table. One thing you can do is in the microflow where you call the rest service, you can retrieve the two objects that are created by the import mapping, and then create a new object that contains information from both tables. 

In this scenario, your domain model will have two tables that are non-persistent (that will hold the rest service response), and then a third table that is persistent (that will hold the address information)

answered