I have some customers in ArrayList and when I want through Postman delete (with id) it is not working : 500 - Internal Error. Please Could someone help me ?
Delete customer DELETE http://localhost:8080/api/customers/{customerId}
@DeleteMapping("/api/customers{customerId}")
public void deleteCustomer(@PathVariable Long customerId) {
customers.remove(this.customers.get(Math.toIntExact(customerId)));
}
CodePudding user response:
try like this you did not add "/" in delete mapping.
@DeleteMapping("/api/customers/{customerId}")
public void deleteCustomer(@PathVariable Long customerId) {
customers.remove(this.customers.get(Math.toIntExact(customerId)));
}
CodePudding user response:
Is this how you send the request? http://localhost:8080/api/customers/{customerId} if you are sending like this it won't work because you gave path like this /api/customers{customerId} In my opinion either change the path like this /api/customers/{customerId} or send the request like this http://localhost:8080/api/customers{customerId}