I know that this question mind be asked before couldn't find exact same problem and I'm new to spring technology so be gentle please
I'm trying post an object using postman which is supposed to be added on my DB
object constructor looks like this
public PostedProduct(String name, long price) {
super(name, price, UUID.randomUUID());
}
Mapping function is this
static final String path = "/Products";
@RequestMapping(method = RequestMethod.POST , value = path)
public void setProducts(@RequestParam("name") String name, @RequestParam("price") long price){
service.setProduct(new PostedProduct(name,price));
}
SetProduct is a function I use to add Object to my database debugger is not reaching to that statement. This is what i did to post my JSON object
the following is the error message
"message": "Required String parameter 'name' is not present",
I tried to change function to this and tried some other combinations
@PostMapping(path)
public void setProducts(@RequestBody PostedProduct product)
{
service.setProduct(product);
}
Nothing changed except for the error message
"message": "Required request body is missing: public void Controllers.MarketController.setProducts(Moldels.ProductModel.PostedProduct)"
I'm not looking for a cheap solution I'm trying to learn why. If anyone is willing to help i can provide more detail