Reading DATA send as POST to my Mendix project

0
Hi there, I have a webservice that posts the status of a sensor to a given URL. I have setup a webservice on my own server that reads the data that is send as a JSON object and stores this in my database. However for test purposes I want to use Mendix instead. I have mastered the normal REST call and I am able to POST data and read the response. GET is also no issue to retrieve data from the webservice on my own server. However, I read many forum QA's but haven't found a solution. Is there a way I can create a page in mendix that can receive a POST and reads the JSON object ? Or do I have to go JAVA ? Thanx, Andy.
asked
3 answers
2

You can achieve this with the rest-service module from the app-store (I don't know the difference with the built-in version of Mendix) // EDIT 1 (sorry for skipping some steps Andy):

  1. Create an non-persistent entity with the same attributes as the JSON.
  2. Create a MF that does the processing (input entity step 1) for example 'MyRestHandler'
  3. Goto Project/Settings/Run time
  4. Select a microflow for after startup. For example ASu_InstallRestHandler
  5. Edit the microflow from step 4. Call a java Action called RestServices.CreateMicroflowService
  6. Parameters: 1. 'MyFirstModule.MyRestHandler' (from step 2, use your own modulename as first part), a user role and the last one HTTPMethod.POST
  7. Start the project
  8. Open in the browser 'http://localhost:8080/rest/ to see your endpoint

All details are in https://github.com/mendix/RestServices/blob/mx5-master/README.md

answered
0

Hi Chris, As level 7 this might sound like easy peazy but for me as level 2 this sounds not like advanced or expert but more like Stephen Hawkings brilliancy. Step 1 no problem there. Step 2 would be creation of the object that fills the entity I created in step1.

Step 3; where do I call something after startup (some settings) ?
- Do i call my microflow after the activity RestServices.CreateMicroflowServiceWithPath in MF RestServices.CreateMicroflowService ? - How do I define it has to call MF in step 2 with HTTPMethod.POST ?

Thanx a million if you can help me with this

answered
0

Okay I allmost have it. My microflow gets called when I post something to my Restservice. I would think it should work like below but it doesn't can anybody point me in the right direction ?

On startup my webservice gets started and when I post something my microflow to proces the POSTED data gets started. In my microflow: Parameter/Object FillData from RequestResult entity (Restservice domainmodel). Create object that fills my entitity/attribute with $FillData .ResponseBody (Commit = Yes). A record is created in my entity but with no data. I probably miss one step.

answered