addMenuItem (POST) - adapalav/dev-ent-java-microserv-spring-final-proj-template GitHub Wiki
Add New Menu Item to Restaurant Database
http://localhost:8080/addMenuItem - Add single customer
Method: POST
URL / Path: /addMenuItem /spring-proj-template/addMenuItem
URL Params
Required: dish_name dish_type dish_price
Optional: description
Data Params Headers: KEY VALUE Accept application/json Content-Type application/json
BODY {"dishName": "Pakoda", "dishType": "Apitizer", "description": "Apitizer made of floor", "dishPrice": 5.99}
Success Response:
POST (SET) command success response: Rows updated: 1
Failure Responses:
Connection Failure(One of the scenarios could be when Jetty not running): curl: (7) Failed to connect to ec2-52-88-192-213.us-west-2.compute.amazonaws.com port 8080: Connection refused
No response because of command specific error: (base) admins-MBP-2:~ vijayadapala$ curl http://localhost:8080/spring-proj-template/printAllCustomers {"timestamp":"2020-08-21T23:25:52.409+0000","status":404,"error":"Not Found","message":"No message available","path":"/spring-proj-template/printAllCustomers"}
Error With Incorrect Arguments: This application has no explicit mapping for /error, so you are seeing this as a fallback. Fri Aug 21 16:44:04 PDT 2020 There was an unexpected error (type=Method Not Allowed, status=405). Request method 'GET' not supported
Error sending all keys/values as params: {"timestamp":"2020-08-22T04:17:35.497+0000","status":404,"error":"Not Found","message":"No message available","path":"/"}
Error resending same values (some are UNIQUE): { "timestamp": "2020-08-22T04:44:35.880+0000", "status": 500, "error": "Internal Server Error", "message": "StatementCallback; SQL [INSERT INTO menu_list (dish_name, dish_type, description, dish_price) VALUES ('Pakoda','Apitizer','Apitizer made of floor','5.99');]; Duplicate entry 'Pakoda' for key 'dish_name'; nested exception is java.sql.SQLIntegrityConstraintViolationException: Duplicate entry 'Pakoda' for key 'dish_name'", "path": "/addMenuItem"}
Code: 200 Content: { id : 12 } Error Response:
<Most endpoints will have many ways they can fail. From unauthorized access, to wrongful parameters etc. All of those should be listed here. It might seem repetitive, but it helps prevent assumptions from being made where they should be.>
Code: 401 UNAUTHORIZED Content: { error : "Log in" } OR
Code: 422 UNPROCESSABLE ENTRY Content: { error : "Email Invalid" }
Sample Call: curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data "{"dishName": "Pakoda", "dishType": "Apitizer", "description": "Apitizer made of floor", "dishPrice": 5.99}" "http://localhost:8080/addMenuItem"
Notes: 21st August 2020