Bad Request HTTP 400 Error

47 views
Skip to first unread message

Hemanth Kumar

unread,
Jan 19, 2025, 2:30:55 PMJan 19
to Django REST framework

I’m building an inventory management app and this is one part of it.

1. Inventory Management App (inventory)

This app is responsible for managing raw materials and products inventory. It also includes categories to better organize products.

  • Models:
    • RawMaterial: Manages inventory for raw cloth rolls (e.g., width, length, remaining quantity).
    • Product: Manages inventory for finished products like shirts and pants.
    • Category: Represents different categories of products (e.g., shirts, pants) with fields name and description.
    • Stock: Records stock related to each product and Warehouse.
  • Views:
    • CRUD operations for raw materials, products, and categories.
    • View available stock.
  • Endpoints:
    • /api/inventory/raw_materials/
    • /api/inventory/products/
    • /api/inventory/categories/
    • /api/inventory/stock/

I have Django as backend with a react frontend. I don’t have much coding background but I can understand the basics. I used chatgpt to help with my coding.
I have the Product model which includes its name, code, quantity, size, price, etc.
I have the Stock model which will update the quantity of the product from each of its entry.
I was able to show the Stock List on the page. When I added the CRUD operations to it, it seems to fail due a datatype mismatch when sending a PUT request to the API.
I have attached images for the GET request: GET.png
Even from the REST framework page “http://127.0.0.1:8000/api/inventory/stock/1/” it fails (json), but with HTML form it works.
Here is the image for the PUT: PUT.png

Here is the output from the terminal:
Bad Request: /api/inventory/stock/1/
[19/Jan/2025 14:25:19] "PUT /api/inventory/stock/1/ HTTP/1.1" 400 11829

GET.png
PUT.png
Reply all
Reply to author
Forward
0 new messages