February 2018
Intermediate to advanced
406 pages
9h 55m
English
Open a browser and hit the following URL: http://localhost:8080/product/1.
You should get back the following response:
{"id":1,"name":"Oranges ","catId":2}
Now, try the other service (URL—http://localhost:8080/productIds). What response do you get? An error, as follows:
There was an unexpected error (type=Bad Request, status=400).
Required int parameter 'id' is not present
Can you guess why? It is because the service definition that you wrote had a method expecting a request parameter:
@RequestMapping("/productIds")List<Integer> getProductIds(@RequestParam("id") int id) {
So, the URL is expecting an id and as you did not supply it, it gives an error.
Give the parameter and try http://localhost:8080/productIds?id=5 ...
Read now
Unlock full access