The PATCH Method: Changing a Price

How an administrator changes part of a product’s data: a PATCH request with the price only, code 200, and an updated column in the database.

About the product

Alex, QA Team Lead

Hi! We’ve learned to add products. But more often a catalogue just needs a small fix: for example, changing a price. Today we look at how an administrator changes the price of a product.

Quick reference

The PATCH method

PATCH /api/v1/products/3 means “change partially”. The request body has only the fields that need to change; the others stay as they were.

Code 200 OK

A success response. For PATCH the server usually returns the whole product in the body, already with the changes.

PATCH and PUT

PATCH changes part of the data, PUT replaces the object completely. To fix a single field, PATCH is more convenient.

What a tester checks

The response code is 200, and the body has the product with the new price. In the database only the price changed; the name and the id are the same. The new price is visible in the admin panel and in the catalogue.