Create API From Mendix Application

0
Hi,   We Would like to Create an API, In which the output will be from our Mendix application, a specific table data will be fetched upon calling the API. In a JSON Format.   For Example, project name: school management, table : attendance.  Create an API within the school management application.  This Api will be called in some other project/dashboard(not mendix application). so we can fetch details from school management app and display.   Any Suggestions or workarounds to achieve this requirement.   TIA.    
asked
5 answers
3

Hi Ganesh Adapala

1-Go to the Entity that you want to expose.

2-Right-click on it and select expose as REST resource 

and Mendix will do the Job for you 

image.png

3- go to the Publish REST Service where you can edit your endpoint and methods

This is the easiest way

But I recommend you This Learning path 

Please recommend this answer as an accepted answer if it answers your question

Thank you

 

answered
1

Try the following steps :

 

  1. Define the API Endpoint:

    • In your Mendix application, create a new Microflow or REST service that will handle the API request.
    • Specify the input parameters and expected output structure.
  2. Retrieve Data from the Database:

    • Use Mendix database connectors or microflow actions to retrieve data from the "attendance" table in the school management application.
  3. Transform Data to JSON:

    • Convert the retrieved data into JSON format. You can use the built-in functions or create custom microflows to structure the data as needed.
  4. Expose the Microflow as a REST Service:

    • If you created a Microflow, expose it as a REST service by configuring a REST operation with appropriate methods (e.g., GET).
    • If you created a REST service directly, make sure to configure it to receive and respond in JSON format.
  5. Secure the API (Optional):

    • Depending on your security requirements, you may want to implement authentication and authorization mechanisms to secure the API.
  6. Test the API:

    • Test the API within the Mendix application using tools like Postman to ensure that it retrieves and returns data correctly.
  7. Call the API from External Project/Dashboard:

    • In your external project or dashboard, use standard HTTP requests or libraries to call the API endpoint created in Mendix.
    • Parse the JSON response to extract the required details for display.
  8. Handle Errors and Exceptions:

    • Implement error handling mechanisms in both the Mendix application and the external project to manage unexpected scenarios.

 

You can reach out to me if you get stuck in any step.

answered
0

please follow the document below : 

https://docs.mendix.com/howto/integration/publish-rest-service/

 

answered
0

The easiest way is to use a published OData service.

 

Published REST services allow you to have more control over specific operations and what the JSON looks like exactly, but they are somewhat more difficult to model.

answered
0

After the Crash Course suggested by Loai (or the Rapid course) , I would recommend that you work on the Import / Export Learning path and specifically look at this section about exposing a REST service to get a basic understanding on how integrations work in Mendix. 

answered