How do we display JSON responses in REST API to datagrid view?

0
I am new to Mendix and I’m wondering how do we display the data below in datagrid view in Mendix. The REST API returns the data below:   { "errors": [ { "source": { "pointer": "/data/attributes/firstName" }, "title": "Invalid Attribute", "detail": "First name must contain at least three characters." }, { "source": { "pointer": "/data/attributes/firstName" }, "title": "Invalid Attribute", "detail": "First name must contain an emoji." } ] }   I already created a Domain Model and defined it in Message Definitions. I also created an import mapping to create a new object. When i checked the debugger, seems like its returning empty/null.
asked
3 answers
1

Hi Ryan,

I was able to import and show this data. This is how I did it…

Firstly, create the JSON structure from that example data at http://dummy.restapiexample.com/api/v1/employees

Next create an Import Mapping for this JSON data

I had Mendix create the domain model for me automatically from the JSON data.
From this data you can create a page. The data starts at Root, so you need that in a Data View, and inside that you need a Data Grid to show the JsonObject list by association from the Root.

Now you can download the data and show it in a page using a simple microflow. In the response make sure you apply your import mapping and return the Root as a variable, I called mine $vRoot. You pass that as the parameter to your Show Page action.

When you run that microflow you should get the data back like this…

Hope this helps!

answered
1

Hi Ryan,

I was able to import and show this data. This is how I did it…

Firstly, create the JSON structure from that example data at http://dummy.restapiexample.com/api/v1/employees

Next create an Import Mapping for this JSON data

I had Mendix create the domain model for me automatically from the JSON data.
From this data you can create a page. The data starts at Root, so you need that in a Data View, and inside that you need a Data Grid to show the JsonObject list by association from the Root.

Now you can download the data and show it in a page using a simple microflow. In the response make sure you apply your import mapping and return the Root as a variable, I called mine $vRoot. You pass that as the parameter to your Show Page action.

When you run that microflow you should get the data back like this…

Hope this helps!

answered
0

Do you want the errors displayed in a Datagrid*) or those thousands of employees? And what is you question? You seem to be trying to consume a REST API that returns the employee data.

If the returned error message is your question, then ask the publisher to explain the errormessage. Either personally or by checking her documentation.

If the returned data seems empty, then that is probably because during processing the REST-call’s response, the big part of the data is stored in the database and you only have the object Root in memory.  Do a retrieve by association from object Root to get the data.

 

*) a Datagrid contains multiple objects, a Dataview contains only one object

answered