Store data from a POST to a restservice into a persistable entity

0
I have created a webservice in my Mendix project that can receive a POST from an external party. I need this because I have a LoraNode that sends data to a URL I can specify. I followed the steps as explained in the tutorials and for test purposes I added a create object, commit to database action in the microflow that gets called in the webservice. This works fine because everytime I do a POST a record gets createed. However, I am not able to receive the contents of the post. Here is what I thought that should work. On startup my webservice gets started and when I POST data to webservice my microflow to process the POSTED data gets started. In my microflow I have a Parameter/Object FillData from RequestResult entity (Restservice domain model). Create object that fills my entity/attribute with $FillData .ResponseBody (Commit = Yes). A record is created in my entity but with no data. What I understood is that the data of a POST ends up in the non persistable entity RequestResult . I probably miss one step ? Any help or a direction would highly be appreciated.
asked
4 answers
0

Andy,

If that is the case just create a non persistent entity with a you prefer(this name does not matter for the json input) and put it in a functional domain model(not the REST module). This entity should contain one attribute with the name MyData exactly as is in the json request. This entity should be the only parameter of the microflow that is triggered from the service.

This should be sufficient to get the data into your application, if you would like to store it in a persistent entity just create this new object and copy the attribute.

Can you get it to work now?

answered
2

Pretty uncool reaction of you before, since i am only and still would like to help you:

The RequestResult object from the Restservice domain model is only used with consumed services so from Mendix to the outside world. Therefore the attribute responsebody is not filled in your published service. The idea is that you create a non persistent entity with attributes that are consistent with the json from the input request. Mendix converts this JSON automatically when the post is done to the mendix object.

Can this be of help to you?

answered
0

Not sure if i understand you correctly, but what you should do in order to recieve a POST rest service in Mendix is publish a REST post action from the start up with a specific url path and microflow that is called when the POST action is triggered.

In this microflow you should create a non-persitant entity with attributes that are the parameters or body of the incoming REST action. You can use the microflow and non-persistent entity to manage the data in the way that you would like.

answered
0

Maarten, Sorry but I have been working on this for a week and cannot get it to work... Offcourse not your fault...

What would be the name of the entity and in what Domain model should it exist ? I only POST this line of JSON: {'MyData':'02000555092137000005000000000000'} and I don't need to do anything in my microflow ? So I can connect a persistent entity with a relationship to my non persistent to store the incoming data as I will need the data in the future ?

answered