Exporting Data as REST service from API

1
I am trying to expose the rest service of an app that I am working on and I have been following the mendix documentation on how to do so. I am getting an error saying “Export mapping does not support mapping type returned by a microflow.” Does anyone know how to fix this error? I was under the impression that the mapping was used to convert the domain model entity along with its associations into a formatted JSON string. Then that is put into an http response and exported to wherever it it consumed. That is how the Mendix documentation "Publish a REST Service" does it at least. When I store the result in a JSON string in my microflow, it will just give me another error that says "When a REST service operation has an export mapping defined, the microflow should return an Object or a List." I am ultimately trying to export data from my mendix app that has the associations of my domain model formatted as a Json file that I can consume elsewhere. I also tried changing the loglevel to Trace but it didn't fix the error.    
asked
2 answers
0

I cannot know what you already tried or did not try, but there are some things that you could possibly do, that maybe will help:

- Within your rest service you can open the operation and change the export mapping to none, and from there you maybe have to also change your microflow return object to none

- another possibility is to make an export mapping based on your json string. This can be done by creating a json structure document and a export mapping where you select you json structure as schema source, then give back the first object within you export microflow

answered
0

Chad,

It sounds like you have created a Published REST service operation that returns data to the requester using an Export mapping.  If this is the case, the microflow that operation points to should return an object or list of objects (depending on what the export mapping expects).  You don’t need to convert the data into JSON yourself, the Mendix engine will do that.

For example, if you define an export mapping to export and Invoice and all of the Line Items on that invoice, your microflow would need to return a single Invoice object.  If your export mapping is for a list of invoices, your microflow should return a list of invoices.  Note that you do not need to retrieve or explicitly pass any line items back from your microflow.  The export mapping will gather all of the line items for each invoice and include that in the JSON returned by the operation.

Hope that helps,

Mike

answered