heather-yaple / auth-me-project

Repo for Auth Me project
0 stars 1 forks source link

Create a Spot #7

Closed heather-yaple closed 1 month ago

heather-yaple commented 2 months ago

Creates and returns a new spot.

joe-corcoran commented 1 month ago

Create a Spot Creates and returns a new spot.

Require Authentication: true

Request

Method: POST

Route path: /api/spots

Headers:

Content-Type: application/json Body:

{ "address": "123 Disney Lane", "city": "San Francisco", "state": "California", "country": "United States of America", "lat": 37.7645358, "lng": -122.4730327, "name": "App Academy", "description": "Place where web developers are created", "price": 123 } Successful Response

Status Code: 201

Headers:

Content-Type: application/json Body:

{ "id": 1, "ownerId": 1, "address": "123 Disney Lane", "city": "San Francisco", "state": "California", "country": "United States of America", "lat": 37.7645358, "lng": -122.4730327, "name": "App Academy", "description": "Place where web developers are created", "price": 123, "createdAt": "2021-11-19 20:39:36", "updatedAt": "2021-11-19 20:39:36" } Error Response: Body validation errors

Status Code: 400

Headers:

Content-Type: application/json Body:

{ "message": "Bad Request", // (or "Validation error" if generated by Sequelize), "errors": { "address": "Street address is required", "city": "City is required", "state": "State is required", "country": "Country is required", "lat": "Latitude must be within -90 and 90", "lng": "Longitude must be within -180 and 180", "name": "Name must be less than 50 characters", "description": "Description is required", "price": "Price per day must be a positive number" } }