Why does my API response assume of type object and not of type LIST?

0
I have exposed an ENTITY as a published rest service (It has records stored in it) . Then, I have consumed it in the same app to test it. In the microflow, I have used the GET method to get all records. Yet, the response type stored in variable is of OBJECT type and not LIST.  It also says NO RECORDS to show on the page when I locally ran it.
asked
3 answers
0

Hi Priya, the REST api can output a dataset (list). This needs to be the output of the microflow of your operation. If you return a List of Objects, that will be the output.

If you expose a list you need to configure a Export Mapping.

 

See for more information on Operations: https://docs.mendix.com/refguide/published-rest-operation/

answered
0

I would like to suggest you follow this learning path to run you through the integration basics and has a step by step approach for setting up a REST service (both publish and consume). 

 

If you publish a REST service from an entity, you should get the option to specify the type of GET (All and by Key). This will create a corresponding microflow which is triggered when calling the correct service. By default this will be <appurl>/rest/<servicename>/v1/<entityname>  for get all. 

 

In your "publish app", you can also use Swagger UI to test it. See test section of the above mentioned learning path.

 

 

Update: Microflow calling the rest service

image.png

Note: Have to check why the second action has (Not set) for the entity. Could be a mx 10.6.1 issue...

 

And the simple domain model

image.png

answered
0

Hi Priya,

In the published service you need to make sure done the following steps:

  1. prepare the structure you need to export. you need to create export mapping according to structure. I prefer to create your structure through a message definitions, then you have the option to generate export and import mapping automatically from message definitions.
  2. use generated export mapping in published services.
  3. use generated import mapping in consumed service.
  4. get the URL of the published service->operations  -> example location
  5. test the published operation in Postman.
  6. test the published operation in the project you need to apply.

 

 

answered