The POST Method: Adding a Product

How an administrator adds a product to the catalogue: a POST request, the request body, code 201, and a new row in the database.

About the product

Alex, QA Team Lead

Hi! You already know how a customer loads the BB Food catalogue. Now let’s look at the other side: the shop has an admin panel where an administrator adds new products. Here the client no longer just reads data — it sends data to the server.

Quick reference

The POST method

POST /api/v1/products means “create”. The client sends data in the request body, and the server saves it in the database. Unlike GET, POST changes data on the server.

Request body

The data the client sends to the server, most often in JSON. For a new product it is the name and the price.

Code 201 Created

The success response to a creation. In the response body the server usually returns the created object, already with its identifier.

Identifier (id)

The client doesn’t send it: the unique number of a new record is assigned by the database.

Repeating POST

Every POST creates a new record, so a repeated request with the same data produces a duplicate. GET has no such problem: it only reads data.

What a tester checks

The response code is 201 (or whatever the team agreed on). The response has an id, and the name and price match what was entered. A new row appeared in the database, and a customer sees the product in the catalogue.