Calling an REST API

Hello, I'm trying to call an API and GET the users, first I used an Dummy data, Local API like the JSON Data and it worked, but now I want to call an API which has MongoDB Database but its not working. My doubt is that if I connect an external database, can I call an a API with that Database that I connected? Thanks in advance.
5 answers

Hi Spoorthi,


If I understand you in the right way, Here are some insights may help you:


  1. Set up Database Connection:

    • Open Mendix Studio Pro and go to the 'App Explorer.'
    • In the 'App Explorer,' find the 'Database' node.
    • Right-click on 'Database' and select 'New Database.'
    • Choose 'External Database' and provide the necessary connection details for your MongoDB database (host, port, username, password, etc.).
  2. Create Entities:

    • Define entities in Mendix that match the structure of your MongoDB collections. Entities are Mendix representations of database tables or collections.
  3. Create Microflow:

    • Create a microflow in Mendix Studio Pro to fetch data from the external MongoDB database. You can use the 'Retrieve' action from the Database Connector module to query data from the MongoDB collections.
  4. Call Microflow from REST API:

    • Create a REST API in Mendix to expose the microflow. You can use the 'Publish REST' option in the 'App Explorer' to create a new REST service.
    • Configure the REST service to call the microflow you created.
  5. Test the API:

    • Deploy your Mendix app to a server or Mendix Cloud.
    • Test the REST API endpoint using a tool like Postman or any HTTP client to ensure that it's retrieving data from your MongoDB database.

Make sure using error handling to handle error scenarios gracefully and secure your API calls if necessary by adding authentication and authorization mechanisms.



** Kindly  accept my answer if it assist you to solve your problem.


Hi Spoorthi YU

As I understand you want to consume an API from a MongoDB 

I think first of all try to test the endpoint you have on Postman to make sure it works fine.

and it doesn't matter which DB you're using while you calling APIs

Does the GET Activity that you use in the MF returns any error if so 

Please provide with the error to help 


image.pngThe above DummyJSON i.e fake API that I used first and its working.



This the error I am getting while I try to import the users.



Hello @Ahmad Aljaafreh, above is the external database connector you talking about right?