Skip to main content

Endpoint

PUT /api/v1/product-reviews/{id}
Update an existing product review.

Path Parameters

id
integer
required
The unique identifier of the product review to update

Request Body

productId
integer
required
ID of the product being reviewed
userId
integer
required
ID of the user who created the review
rating
integer
required
Rating given to the product (typically 1-5)
comment
string
Text comment or review description

Response

Returns the updated product review object.
id
integer
required
Unique identifier for the review
productId
integer
required
ID of the product being reviewed
userId
integer
required
ID of the user who created the review
rating
integer
required
Rating given to the product
comment
string
Text comment or review description
createdAt
string
Timestamp when the review was originally created (ISO 8601 format)

Status Codes

200
OK
Product review successfully updated
400
Bad Request
Invalid request body or validation error
404
Not Found
Product review not found

Example Request

curl -X PUT "https://api.example.com/api/v1/product-reviews/1" \
  -H "Content-Type: application/json" \
  -d '{
    "productId": 101,
    "userId": 501,
    "rating": 4,
    "comment": "Updated review: Good quality sofa, but the color was slightly different than expected."
  }'

Example Response

{
  "id": 1,
  "productId": 101,
  "userId": 501,
  "rating": 4,
  "comment": "Updated review: Good quality sofa, but the color was slightly different than expected.",
  "createdAt": "2024-01-15T10:30:00"
}

Error Response

When a product review is not found:
{
  "status": 404,
  "error": "Not Found",
  "message": "Product review not found with id: 999"
}

Validation Rules

  • productId is required and must be a valid integer
  • userId is required and must be a valid integer
  • rating is required and must be a valid integer
  • comment is optional but should be a string if provided

Notes

  • The createdAt timestamp is not modified during updates
  • All fields in the request body are required, even if only updating specific fields
  • The review ID in the path parameter must match an existing review

Build docs developers (and LLMs) love