Service Consumption
Table of Contents
How Can I Consume a REST API?
Calling a REST service is simple. First, you define what the external resources you are going to use look like by creating a message definition. The easiest way to do this is usually to create a JSON structure by copying and pasting an example JSON message. Mendix will automatically determine the structure of your message and the applicable attribute types, as illustrated below.
Next, you need to define mappings to import and export data to the external REST service. This is similar to the example above. It is important to note here that you can generate domain model entities if you do not already have the appropriate entities. This is probably the case when you have defined a message based on an example JSON.
Finally, you use the Call REST activity in your microflows to call the REST API. This is simply a case of providing the URL of the API. In the Request and Response tabs, you can define which mappings you want to use.