Creating a REST API
#
IntroductionThe user should create their first API and learn how to a) create an API with the API builder b) set up ingresses and c) test their endpoints. After this section, the user will be familiar with APIs and then moving into the REST and XML sections will be easier to explain.
#
VisionsCorp’s requestIn this integration, we will create a REST API for VisionsCorp (VC). The enterprise makes frequent use of APIs for nearly all business needs so a solid understanding of the creation process is critical. Luckily you are in good hands because Jetic provides a simple interface where APIs can be created quickly and efficiently. Lets get started.
#
Integration Ingredients:- REST API
- Log
#
Goals:- Create an API with API Builder
- Create an Ingress
- Test the API with Postman
#
Step 1: Create a new integration- Create a new integration
- Name the integration CountriesAPI
#
Step 2: Create the API- Click on the APIs 🔌 in the left sidebar
- Click on the Create New next to OPTION and then click on the ✏️ Create New
- Give it a Name, (for this Demo we will be calling it Countries)
- Give the API a Version of 1.0
- For the Host use countries.devdemo.jetic.io
#
Step 3a: Creating an API Endpoint- Click on the (+) next to the API with the arrows to add an endpoint
- In the empty field add /countries
- Click on the + to Add Operation
- A Create Operation modal will pop up. For the name, add countries
- For the Method, leave it as a GET
- For this demo, we will leave Consumes and Produces as it is, namely, application/json
- Drag the GET countries to route-1’s swing lane
- Add a Log under the Rest API Get
#
Step 3b: Configuring traits- To properly set up the API we have another step, click on Traits in the left sidebar
- You will see an Ingress trait, click it and you will see three options: Enabled, Host, and Auto
- Check both the Enabled and the Host boxes.
- In the field that pops up, enter countries.devdemo.jetic.io
- Your API is now ready to test
At VisionsCorp it is best practice to use the API platform Postman to test your Integrations. To get started with Postman, click here for a quick setup.
#
Step 4: test in PostmanIn Postman create a new GET request
In the GET URL add countries.devdemo.jetic.io/countries (this is the Ingress you added with the route appended)
Run the integration in Jetic using the ▶️
Once the logs say: INFO [io.quarkus] (main) Installed features: […] go back to Postman
Press Send in Postman to send the GET request back to Jetic
Back in Jetic, Click on the Execution Logs. You should see the headers and body get logged (if you changed the log message you will see that logged)
🎉 Congratulations you have successfully created your first API in Jetic! 🎉