simple-review-server/docs/POST.md
2024-09-16 12:14:50 -04:00

1.3 KiB

POST

/api/post

Encoding: JSON
Response Codes: 201, 400, 500
Response Format: JSON

Schema:

Field Type Info Required
username string 2-30 characters true
rating number from 0.5-5, only .5 increments true
title string 0-50 characters false
content string 0-2000 characters false

Example Objects (being submitted by a client):

Good Request

{
    "username": "bob",
    "rating": 4.5,
    "title": "All fields",
    "content": "This user review contains all required and allowed fields!"
}

Server Response (200):

{
    "message": "review was sent"
}

Bad Request

{
    "username": "hacker",
    "rating": -3
}

Server Response (400):

{
    "error": {
        "type": "ValidationError",
        "message": "rating must be a positive number"
    }
}

Additional info: When submitted, the server will add two more fields to your review and store this info server side:

Field Type Info
id string 6 randomly-generated characters
timestamp string ISO timestamp