How to configure Import Mapping to return a List of Patients from a REST service?

0
Hi everyone,I'm using Mendix 11.6.5 and trying to expose a REST service that returns multiple patients.My goal is to call a REST service and return a List of Patients that I can use in a microflow/page.Questions:How should the Root element be configured in the Import Mapping?Should the Root object be mapped to a non-persistent entity or left unmapped?How can I configure the Import Mapping so that it returns a List of Patients instead of a single object?I've attached a screenshot of my Import Mapping configuration.Any guidance or example configurations would be greatly appreciated.
asked
2 answers
1

Hi Varsha M


I think there's some confusion in your question. You said you want to expose a REST service, but Import Mapping is used when consuming a REST service, not when exposing one. and you are aksing for import mapping? things got mixed up.


If you are searching to expose or consume kindly check the mendix documentation.


I hope this helps

answered
0

If your REST response contains multiple Patient objects, then the Root element should represent the collection, not a single Patient object.


The common approach is:

  • Create a Non-Persistent wrapper entity (e.g., PatientResponse) as the Root.
  • Associate it with a 1- association* to your Patient entity.
  • In the Import Mapping, map the root JSON/XML element to the wrapper entity and map the repeating patient nodes to the associated Patient objects.


If your response is simply an array of patients (without a wrapper object), you can leave the root unmapped and configure the repeating element to create a list of Patient objects.


It would be helpful if you could also share:

  • A sample REST response (JSON/XML).
  • A screenshot of your domain model.
  • The current Import Mapping configuration.


That will make it easier to suggest the correct mapping.


Kindly mark this as the accepted answer if it helps.

answered