0

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))); } 
1
  • The answers thus far suggest that the culprit is your path (missing the slash after customers). This is definitely an issue, but this would not cause a 500, internal server error. Share the contents of the error, only then can this question be answered...and yes, you will have to fix that path too. Commented Feb 18, 2022 at 19:39

2 Answers 2

1

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))); } 
Sign up to request clarification or add additional context in comments.

Comments

1

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} 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.