addCustomer (POST) - adapalav/dev-ent-java-microserv-spring-final-proj-template GitHub Wiki

Add New Customer to Restaurant Database

http://localhost:8080/addCustomer - Add single customer

Method: POST

URL / Path: /addCustomer /spring-proj-template/addCustomer

URL Params

Required: first_name last_name email_id user_name phone_no

Optional: addr

Data Params Headers: KEY VALUE Accept application/json Content-Type application/json

BODY {"firstName": "Hinkmond", "lastName": "Wong", "email": "[email protected]", "usrName": "hinkmond", "phoneNo": "333-333-3333", "address": "333 Ninth St."}

Success Response:

  1. POST (SET) command success response:curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data "{"firstName": "Hinkmond", "lastName": "Wong", "email": "[email protected]", "usrName": "hinkmond", "phoneNo": "333-333-3333", "address": "333 Ninth St."}" "http://localhost:8080/addCustomer" HTTP/1.1 200 Content-Type: application/json;charset=UTF-8 Content-Length: 15 Date: Fri, 21 Aug 2020 23:56:14 GMT

Failure Responses:

  1. 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

  2. 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:25:17.565+0000", "status": 500, "error": "Internal Server Error", "message": "StatementCallback; SQL [INSERT INTO customer_list (first_name, last_name, email_id, user_name, phone_no, addr) VALUES ('Hinkmond','Wong','[email protected]','hinkmond','333-333-3333','333 Ninth St.');]; Duplicate entry '[email protected]' for key 'email_id'; nested exception is java.sql.SQLIntegrityConstraintViolationException: Duplicate entry '[email protected]' for key 'email_id'", "path": "/addCustomer" }

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 "{"firstName": "Hinkmond", "lastName": "Wong", "email": "[email protected]", "usrName": "hinkmond", "phoneNo": "333-333-3333", "address": "333 Ninth St."}" "http://localhost:8080/addCustomer"

Notes: 21st August 2020