Skip to content

Giridhar706/ASP.NET_Core-BookStore_RESTfulAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Book Store RESTful API - ASP.NET Core

A RESTful API project built using ASP.NET Core for managing books and authors.
This project demonstrates CRUD operations, attribute routing, API testing using Postman, and HTTP debugging using Fiddler while following RESTful API principles.


Features

  • RESTful API implementation
  • CRUD operations for Books
  • Author resource management
  • Association between Books and Authors
  • Attribute Routing
  • Proper HTTP Status Codes
  • JSON Responses
  • In-Memory Database
  • Swagger Integration
  • Postman API Testing
  • Fiddler HTTP Debugging
  • Input Validation
  • Error Handling

Technologies Used

  • ASP.NET Core (.NET 10)
  • C#
  • Swagger / Swashbuckle
  • Postman
  • Fiddler Classic
  • Visual Studio 2026

Project Structure

BookStoreAPI
│
├── Controllers
│   ├── BooksController.cs
│   └── AuthorsController.cs
│
├── Models
│   ├── Book.cs
│   └── Author.cs
│
├── Data
│   └── AppDbContext.cs
│
├── Program.cs
├── appsettings.json
├── BookStoreAPI.csproj
└── README.md

API Endpoints

Books APIs

Get All Books

GET /api/books

Get Book By ID

GET /api/books/{id}

Create Book

POST /api/books

Sample Request Body:

{
  "title": "Atomic Habits",
  "authorId": 1,
  "publicationYear": 2018
}

Update Book

PUT /api/books/{id}

Sample Request Body:

{
  "id": 1,
  "title": "Updated Book",
  "authorId": 1,
  "publicationYear": 2020
}

Delete Book

DELETE /api/books/{id}

Authors APIs

Get All Authors

GET /api/authors

Get Author By ID

GET /api/authors/{id}

Create Author

POST /api/authors

Sample Request Body:

{
  "name": "James Clear"
}

Get Books By Author

GET /api/authors/{authorId}/books

This endpoint demonstrates the relationship between authors and books using RESTful URI routing.


HTTP Status Codes Used

Status Code Meaning
200 OK Successful request
201 Created Resource created successfully
400 Bad Request Invalid request data
404 Not Found Resource not found

Validation Implemented

  • Required book title
  • Required author name
  • Publication year validation
  • Invalid author ID validation
  • Proper error responses

Error Handling

The API gracefully handles:

  • Invalid IDs
  • Missing resources
  • Invalid request data
  • Validation failures

Example Error Response:

{
  "message": "Book not found"
}

Swagger Integration

Swagger UI is enabled for easy API testing and endpoint visualization.

After running the project:

https://localhost:{port}/swagger

Swagger allows testing all:

  • GET APIs
  • POST APIs
  • PUT APIs
  • DELETE APIs

directly from the browser.


Testing Using Postman

The API was tested using Postman for:

  • GET requests
  • POST requests
  • PUT requests
  • DELETE requests
  • Error handling
  • Invalid request testing
  • JSON response verification

Example GET Request:

GET https://localhost:{port}/api/books

Debugging Using Fiddler

Fiddler Classic was used to:

  • Monitor HTTP traffic
  • Inspect HTTP requests
  • Inspect HTTP responses
  • Verify request methods
  • Verify response headers
  • Verify status codes
  • Debug HTTPS requests
  • Analyze JSON responses

RESTful Principles Followed

  • Proper HTTP Methods
  • Resource-Based URIs
  • Stateless Communication
  • Standard HTTP Status Codes
  • JSON Data Exchange
  • Clean Attribute Routing

Sample JSON Response

[
  {
    "id": 1,
    "title": "Harry Potter",
    "authorId": 1,
    "publicationYear": 1997
  }
]

How To Run The Project

Prerequisites

  • Visual Studio 2026
  • .NET 10 SDK

Steps To Run

1. Clone Repository

git clone <repository-url>

2. Open Project

Open:

BookStoreAPI.csproj

in Visual Studio 2026.


3. Restore NuGet Packages

If packages are not restored automatically:

Install:

Swashbuckle.AspNetCore

Version:

6.6.2

4. Build Solution

Build → Build Solution

Shortcut:

Ctrl + Shift + B

5. Run Project

Press:

F5

Swagger UI will open automatically.


Testing Checklist

CRUD Operations

  • GET all books
  • GET book by ID
  • POST create book
  • PUT update book
  • DELETE book

Authors APIs

  • GET all authors
  • GET author by ID
  • POST create author
  • GET books by author

Validation

  • Required fields validation
  • Invalid data handling
  • Error responses

Testing Tools

  • Swagger
  • Postman
  • Fiddler

Learning Outcomes

  • Building RESTful APIs using ASP.NET Core
  • Implementing CRUD operations
  • Using Attribute Routing
  • API testing using Swagger and Postman
  • HTTP debugging using Fiddler
  • Handling validations and exceptions
  • Designing RESTful endpoints

Author

Giridhar Gopal


License

This project is created for educational and academic purposes.

About

A RESTful Book Store API built using ASP.NET Core with CRUD operations, attribute routing, Swagger, Postman testing, and Fiddler debugging.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages