REST calls : non-persistable objects are not mapped in the JSON body
0
Hi there, Weird bug : I’m calling a REST service, using a hierarchy of non-persistable objects (generated automatically by Mendix based on the JSON payload). The root object is well mapped into JSON, but as soon as there is a 1-many relationship with other non-persistable objects, they’re not mapped into JSON, just like if they didn’t exist… The only workaround I found was to retrieve each of these objects prior calling the REST service (without changing any of their content), and by doing so, the mapper converts them into JSON … Anyone had this issue ? NB: the hierarchy of non-persistable objects comes from the client side I tried to commit these objects, but it doesn’t change anything even weirder : even if the execution flow is not going through the “retrieve” actions, the payload is well mapped into JSON ! but if I remove the “retrieve actions” from the code, the payload is not okay. wtf My non-persistable objects : the original microflow : Which leads to this payload : { "message": "this is a test", "redirect_url": "https://picpedia.org/handwriting/images/success.jpg", "is_ordered": false, "embedded_signing": true } But if I change the microflow into this (the test is hard coded to “false”, so the flow doesn’t go into retrieve actions ...) : Then the payload becomes : { "sources": [ { "id": 57322315, "type": "original", "source_id": 1 } ], "message": "this is a test", "recipients": [ { "email": "francois+local@kohomai.com", "first_name": "Francois", "last_name": "Lecomte", "recipient_id": 1 } ], "redirect_url": "https://picpedia.org/handwriting/images/success.jpg", "is_ordered": false, "embedded_signing": true }
asked
François Lecomte
2 answers
0
Indeed: WTF. Normal behavior does map all objects and their attributes.
I did and mf Test_Mapping and the payload was fine and complete, like this
Likely the problem resides in the passing of the data from the client-side. Like you say: “the hierarchy of non-persistable objects comes from the client side“. What do you mean by that. From a react-widget? Very likely the technique used to pass the data from the client-side, does not put the entire tree structure in memory, until it is specifically requested, and apparently an export mapping does not trigger this.