albanoj2/order-rest-backend

POST request is not working

Closed this issue · 9 comments

Hi
I am New to JAVA and I was trying to use run your code.. its up and running. I am able to view empty order on link http://localhost:8080/order.
But could you please help me with the format of POST request since its not documented that what params need to send while making POST request. i am getting below error while trying to POST a order

{"timestamp":1613580901577,"status":400,"error":"Bad Request","exception":"org.springframework.http.converter.HttpMessageNotReadableException","message":"Required request body is missing: public org.springframework.http.ResponseEntity com.dzone.albanoj2.example.rest.controller.OrderController.createOrder(com.dzone.albanoj2.example.rest.domain.Order)","path":"/order"}

I am sure there must be some specific format of POST request .. I am using below POST request
http://localhost:8080/order?message=firstorder

Are you adding the payload in the request body ?

what are you using to make the request ? postman ?

This payload worked for me
{"id":1,"description":"my order","contInCents":30,"isComplete":true}

Also had to set the header
Content-Type: application/json

Issue fixed