Issue
Suppose i have entered the fields in my requestDto and made a post call which will save the data in database and if i again hit the post api with same requestDto fields, the entries should not be saved. How i can achieve this functionality in spring boot
Solution
Bear in mind that POST
requests are not idempotent: with multiple identical requests you may end up with multiple identical resources getting created.
So, to prevent resources from getting created multiple times, you'll need some sort of validation in your server. You could rely, for example, in a unique constraint in your database and, if the constraint is violated, you can refuse the request with 409
.
Answered By - cassiomolin
Answer Checked By - Marie Seifert (JavaFixing Admin)