Status Codes
Explanation of HTTP status codes used, when to use them, etc.
TABLE
GET
/resource
Successful
200
OK
Data is successfully retrieved.
GET
/resource/:id
Record not found
404
Not Found
"Resource record not found"
GET
/resource/:id
Successful
200
OK
Data is successfully retrieved.
POST
/resource
ForbiddenError (Creation not allowed)
403
Forbidden
"You are not authorized to perform this action"
POST
/resource
Successful Creation
200
OK
Data is successfully created.
PUT
/resource/:id
ForbiddenError (Update not allowed)
403
Forbidden
"You are not authorized to perform this action"
PUT
resource/:id
Bad Request
400
Bad Request
"Cannot deactivate resource because it is in use by one or more other resources"
PUT
/resource/:id
Successful Update
200
OK
Data is successfully updated.
DELETE
/resource/:id
ForbiddenError (Deletion not allowed)
403
Forbidden
"You are not authorized to perform this action"
DELETE
/resource/:id
Bad Request
400
Bad Request
"Cannot delete resource because it is in use by one or more resources"
DELETE
/resource/:id
Successful Deletion
200
OK
Data is successfully deleted.
Any
Any
RecordInvalid
422
Unprocessable Entity
Specific model validation errors
Any
Any
NotNullViolation
422
Unprocessable Entity
Specific null violation message
Any
Any
UpgradeRequiredError
426
Upgrade Required
"Resource limit reached. Please upgrade your plan to add more"
Any
Any
PaymentRequired
402
Payment Required
"Your company trial has expired."
Any
Any
Not Authenticated
401
Unauthorized
"User not found, Please log out and log back in."
Any
Any
InternalServerError
500
Internal Server Error
"Something went wrong."
Notes:
This table was created largely based on (1)
api_controller.rb
and (2)note_categories_controller.rb
The "Any" errors (
RecordNotFound
,RecordInvalid
,NotNullViolation, etc.)
are generic error handlers that could be triggered on any type of request (GET, POST, PUT, DELETE) if the corresponding exception is raised.The
ForbiddenError
is raised when the user does not have the necessary roles to perform create, update, or delete actions.The condition "Successful" implies that the operation completed without triggering any of the exceptions handled in the
ApiController
.
Last updated