REST API query with an import mapping

0
Hi, I want to get some data via a REST API request and I can see a response, if I set the response handling option to “store in a string”. In case I am select an existing import mapping file from a JSON, I got only zero values for each json parameter. Does anybody has a idea to solve this issue?  Thanks, Ingo
asked
8 answers
1

Hi Ingo,

Maybe the import mapping doesn't match the JSON result?

You could compare the JSON snippet from the import mapping with your result…

Issues might be in cardinality e.g you expect an array, but the result is only one element, but also the datatypes could have a mismatch...all kinds of errors possible.

Furthermore you can set your loglevels to debug for the JSON import.

Lastly you could post a little more info to this question, so we can better understand :-)

 

Go make it!

Jacob

answered
1

Probably the mapping is wrong. Set the response handling option to “store in a string” and after the rest-call in an import-JSON-activity feed that string to your JSON-mapping and see what happens. Likely you will see the same result but easier to understand and test and tweak until the mapping is right.

Helpful is to create a new JSON_Structure and paste the value of the string into it. This will show you if the received JSON is a valid one.

 

answered
0

Did you create a JSON structure from the response that is stored in the string, and then use the JSON structure to create your import mapping?  Here’s a link to some information that may be helpful.https://docs.mendix.com/howto/integration/consume-a-rest-service

answered
0

I tried my best, but I didn’t make after my vacation. The JSON contains an array. I am created a JSON structure in mendix and copied the reply from the http request function. After that I am created import mapping object, but it looks a little bit different than the example. The root entity is completely empty! And I have modified the requesting microflow and used for the conversion an import mapping block. And it didn’t work… I think the mapping function is not configured correctly, but I can’t find the error. Do you have a hint for me?

Thanks

 

answered
0

Between the “Call REST (GET)” and the “Import from JSO” do a “Retrieve JsonObject_Root” over association from NewGridData and feed that result to the Importmapping.

 

answered
0

Thanks Tim, will change the microflow later and test it. When I am arrive in the office. 

answered
0

@tim 

I tried your workaround and add a retrieve activity to the microflow. But I can’t select the NewGridData object, it’s not listed in the dialog. And I am calling the microflow by a simple button without any parameters. The picture shows my availabe options: 

Sorry for the many questions on this topic, I am still working my way into the Mendix development environment.

answered
0

I managed it. But now I have some new questions… I will create a new topic.

Thanks

answered