...

/

Implement the POST Endpoint for Creating a New Product

Implement the POST Endpoint for Creating a New Product

Learn how to implement products API using Flask to create a new product.

In a REST API, insert (aka create) is used to add a new resource to the existing collection. In this lesson, we’ll see how to implement an API endpoint using POST, which adds/creates a new product to the existing collection of products.

The request object of Flask can be used to retrieve the body of a POST request. The route decorator can be used to map a method to the POST request. Let us see how to implement an API to add a new product by using the request object and the route decorator.

Steps

  1. Open server/api/products_api.py.

  2. Add a new method. Name the method add_product. ... ...

Access this course and 1400+ top-rated courses and projects.