MxBlog

Howto - Calling a REST service from a Mendix microflow

Here's a short example how you can call a REST service from a Mendix Microflow. In this example i'll show you how you can determine the (dutch) address for a given zipcode and housenumber using the service provided by postcodeapi.nu.

  1. Non-persistent entities for Request and Response messages - The Postcode entity contains the request parameters, the Address entity will contain the result of the REST call.

Rest call request and response messages

  1. Microflow to call the Java Action - The microflow can be used to create the request entity, and set the correct values. Next you will call a Java action that will do the actual call.

Microflow REST call

  1. Set parameters for the Java action call - specify how you want to call the Java action, with which entity values.

Java action REST call

  1. Calling the Service using some Java code - This example uses the UniRest library, which makes calling a service pretty straight-forward. All you need to do is use the request entity provided to create the correct URI, and afterwards create a new non-persistent entity to hold the response.

Java code REST call

One more thing: configure the deeplink module...