Accessing API using Ocelot API Gateway
This project contains TWO API'S
- DepartmentAPI
- ProductAPI
Before proceed further please install .NET Core 7.0 , MySQL , Node.js , Postman
First Talk about DepartmentAPI :
This API is Built using .NET Core 7.0, C# , MySQL , EntityFrameworkCore
To run DepartmentAPI first create database in mysql as transflower and import Departments.sql in it
or you can choose any database but don't forgot to edit ConnectionString in CollectionContext.cs
It will run on port 5002
The Second is ProductAPI :
Which is Built using Node.js, Express ,MySQL
To run ProductAPI first create database in mysql as actsdb or you can use already crated Database and import products.sql in it
Make Sure changes in db.js for ConnecionString
It will run on port 3000
After this finally run a Gateway project which have all rounting configuration
It will run on port 5000
If you have any services preconfigured with above ports please make changes
Hope all things gone ok ,mostly it will be ok if you have proper database setup
To run all projects you can just click on run.bat(batch) file
Open Postman for API testing
And Try following URL
- The URL will Show all departments data . request-type GET
http://localhost:5000/departments
- The URL will Show department data by id . request-type GET
http://localhost:5000/departments/13.The URL will Insert department data . request-type POST
http://localhost:5000/departments/insertFor inserting data select Body-> raw -> JSON
The data will be type of JSON Object<b>
{
"name": "Analytics",
"location": "Punjab"
}Id will be automatically inserted as it is auto_incremented
4.The URL will Update department data . request-type PUT
http://localhost:5000/departments/updateFor updating data select Body-> raw -> JSON
The data will be type of JSON Object<b>
{
"id": 15,
"name": "Analytics",
"location": "Punjab"
}It will update data of existing record
- The URL will delete department by id . request-type DELETE
http://localhost:5000/departments/delete/1The Same goes for ProductAPI
- The URL will Show all products data . request-type GET
http://localhost:5000/products
- The URL will Show product data by id . request-type GET
http://localhost:5000/products/23.The URL will Insert product data . request-type POST
http://localhost:5000/products/insertFor inserting data select Body-> raw -> JSON
The data will be type of JSON Object<b>
{
"title": "knor soup",
"description": " spicy ",
"price": 110
}Id will be automatically inserted as it is auto_incremented
4.The URL will Update product data . request-type PUT
http://localhost:5000/products/update/2here 2 is Id
For updating data select Body-> raw -> JSON
The data will be type of JSON Object<b>
{
"title": "knor soup",
"description": " mid-spicy ",
"price": 90
}It will update data of existing record
- The URL will delete product by id . request-type DELETE
http://localhost:5000/products/delete/2Give a ⭐️ if this project helped you!