2024 - Inf 354 Api
2024 - Inf 354 Api
Advanced
Programming
API 1
Learning Outcome:
Learning Objectives:
❖ Introduction
❖ REST
❖ HTTP Verbs
❖ Routing
❖ Database
❖ Practical
API 1
Introduction
API
API GUI
Client User
Server
ASP.NET Core provides a powerful and flexible platform for building restful
APIs with its support for
• HTTP verbs
• Routing
• Model binding,
• Response types.
HTTP Verbs
• Attribute routing uses [Route()] attribute to define routes. The Route attribute
can be applied on any controller or action method.
public class StudentController : ApiController
{
[Route("api/student/names")]
public IEnumerable<string> Get()
{
return new string[] { "student1", "student2" };
}
}
Practical – (Creating a new WebAPI)
Practical – (Creating a new WebAPI)
Practical – (Creating a new WebAPI)
ZAHikes
Hikes
Name Type
Province
ID Unique Identifier (GUID)
Name Type
Name String
ID Unique Identifier (GUID)
Description String
Code String
LengthInKm Double
Name String
HikeImageUrl String
RegionImageUrl String
ProvinceId Unique Identifier (GUID)
Difficulty
Name Type
Name String
The End