NativeREST

Content Type: Module
Categories: Import/Export

Overview

Lets you call a rest API from a nanoflow and then parse the JSON to Mendix objects.

Documentation

Demo urlhttps://callrestservicenan-sandbox.mxapps.io/

Download a sample here – https://www.notion.so/gajduk/Mendix-Native-REST-example-1b1582a36fbc4d4da76919bdb77d77d5

 

Description

Has two javascript actions:

  • CallRestService

Calls a WEB endpoint at a specified URL and waits for a response.
Interprets the response as text/string. HTTP Method and headers can be set.

  • ImportJson

Parses a JSON string to Mendix objects.
The JSON keys are mapped to attributes/references based on name, so they must match exactly.
The user has to have access to create the object and write the attributes which are part of the JSON.
Date time can be parsed as epoch number of milliseconds or from a string with a dateTimeFormat (see example).
If a key in the json can not be mapped to an attribute it will be skipped silently i.e. no errors will be thrown.

The javascript action always returns a list even if there is only a single element at the root level.
 

Typical usage scenario

Calling a REST api from the client-side. Can be used for example in native apps.

Features and limitations

JSON import automatically maps key to attributes based on name. Nested objects/arrays are mapped to associated entities by key. See example

Attribute and reference names must match the JSON keys exactly otherwise they will not be parsed.

Dependencies

  • None

 

Releases

Version: 1.2.0
Framework Version: 8.4.1
Release Notes: * Added an option to retrieve the full response including headers and status instead of just the body * Fixed issue with lowercasing headers
Version: 1.1.0
Framework Version: 8.4.1
Release Notes: * fixed bug when dealing with entities that have no access rights defined (thanks Jan de Lange for the feedback) * added fault tolerance by catching and logging errors during javascript action init
Version: 1.0.0
Framework Version: 8.4.1
Release Notes: Initial upload