Handeling multiple REST responses top same API call

0
I want to build a page that can call Rest API calls dynamically, meaning, that the user can choose what to include in the call. But still using the same REST service resource.  Now there are a couple of different responses I could get. E.g.: If it goes well: { "routes": [ { "id": "1793a897-0843-4957-ab63-c61e0f13aff2", "sections": [ { "id": "c3e300ab-a880-4fab-9bb2-702355b2bf6b", "type": "vehicle", "actions": [ { "action": "depart", "duration": 126, "instruction": "Head toward Chausseestraße on Invalidenstraße. Go for 1.2 km.", "offset": 0 }, { "action": "arrive", "duration": 0, "instruction": "Arrive at Invalidenstraße.", "offset": 78 } ], "departure": { "time": "2019-12-05T15:15:56+01:00", "place": { "type": "place", "location": { "lat": 52.53100287169218, "lng": 13.38464098982513 } } }, "arrival": { "time": "2019-12-05T15:18:02+01:00", "place": { "type": "place", "location": { "lat": 52.52639072947204, "lng": 13.368653766810894 } } }, "summary": { "duration": 126, "length": 1200 }, "polyline": "BG2znmkDi89wZ9ChKAA1IvfAArH5cAArHvbAA1CrJAArF5SAAtP9yBAAT1E3E3QAA_BrH3M9sBAA_F5SAA3KlkBAA1EtNAApB_DAAhC1EAApB1I_D5OAA3ErPAApFtTAAtN_wBAA1GtVAA5U3lCAA_DhOAA3KliBAAtXjvCAArDtLAA1EhQAA1CrJAA_BrFAAvbl9CAAhIvZ_FtTrDtLAAV1I1CtNAA1E3QAArLnoB1G5YAAhGhSpBrFAAhC1GAA1FxT", "spans": [ { "offset": 0, "names": [ { "value": "Invalidenstraße", "language": "de" } ], "length": 787 }, { "offset": 49, "names": [ { "value": "Invalidenstraße", "language": "de" }, { "value": "Sandkrugbrücke", "language": "de" } ], "length": 51 }, { "offset": 57, "names": [ { "value": "Invalidenstraße", "language": "de" } ], "length": 362 } ], "transport": { "mode": "car" } } ] } ] } But in case something goes wrong, it could respond with: { "error": "Unauthorized", "error_description": "No credentials found" } or { "title": "Malformed request", "status": 400, "code": "E605001", "cause": "missing field `destination`", "action": "", "correlationId": "4199533b-6290-41db-8d79-edf4f4019a74" } I would assume I need different import mappings to handle these calls no? What is the best way to do this in Mendix?
asked
1 answers
2

I am not sure if I have it completely understand. But you should be able to handle all these answers in one, combined mapping. attributes which wouldn’t be deliverd, would be empty. 

 

The 1 dimensional answers like error the status would be then in one inpersistent entity. 

Do you have the possibility to modify the consuming API?

answered