Coder Social home page Coder Social logo

dealvps's Introduction

dealVPS

This API provides endpoints for managing items in the DealVPS Assignment database.

Prerequisites:

Before testing the API endpoints, make sure you have the following installed:

Postman for testing API requests.

Endpoints

  1. Add an Item

    Endpoint: POST /api/addItem Description: Add a new item to the database.

    Request Body: JSON object with the following fields: name (String, required): The name of the item. description (String, required): A description of the item.

Example Request Body:

json

  {
     "name": "Example Item",
     "description": "This is an example item."
  }

The response will be in the format:

  {
     "id": 1,
     "name": "Example Item",
     "description": "This is an example item.",
     "dateAdded": "2023-10-09T17:35:37.5035933"
  }

Testing:

Open Postman.
Set the request type to POST.
Enter the URL: http://localhost:8080/api/addItem (Replace with your API endpoint).
In the request body, provide the JSON object as shown in the example above.
Click "Send" to add the item.
  1. Get an Item

    Endpoint: GET /api/getItem Description: Get a single item from the database by providing its ID as a query parameter.

    Query Parameters: itemId (Integer, required): The ID of the item to retrieve.

Example URL:

bash

  `https://dealvps.onrender.com/api/getItem?itemId=1`

Testing:

Open Postman.
Set the request type to GET.
Enter the URL with the itemId parameter provided above.
Click "Send" to retrieve the item.
  1. Get All Items

    Endpoint: GET /api/getAllItem

    Description: Get all items from the database.

Testing:

Open Postman.
Set the request type to GET.
Enter the URL: https://dealvps.onrender.com/api/getAllItem.
Click "Send" to retrieve all items.

Error Handling

- 400 error code : If an item with the same name already exists when adding an item, a 400 Bad Request response will be returned.
- 404 error code: If the requested item is not found by its ID, a 404 Not Found response will be returned.

Now you can use Postman to test the API endpoints for creating, retrieving, and listing items in the DealVPS Assignment database.

dealvps's People

Contributors

amosoneh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.