I have to do multiple POST call with same test data. My request body of post contains 3 elements which forms composite key. When i do multiple request i get response code as 409 conflict instead of 201 created from second request hit(First request gets completed with response code 201). What is the best way to delete existing key combination from sql server DB so that i won’t get 409 conflict response. Unfortunately i don’t have DELETE method API call with me.
Could you share more info about the API of the database you’re querying?
If you do not have a delete method you may try to do an update instead and replace by a random value to avoid duplicates.
Thanks for quick reply. My intention is to do multiple POST call when I run my collection suite multiple time in a day. I do have PATCH method but i need to pass whole resource/body in it. I can’t perform remove operation for it. Also any random values might not resolve my problem completely as values are combo values which are configured in other table. If i choose any random values which are not configured in DB that will cause bad data getting inserted/updated in DB.
Unfortunately if you do not have an API that allows to delete entries in the database I don’t think Postman will be able to help as all you can do is send API calls. I’d recommend reaching out to the support for the database you’re working with to see if there’s a way to delete a previously created entry using an API call.
that might be the due to logic of your application. try and regenerate a token in between while doing multiple request. that will solve your prob
@arlemi Thanks for your response. From whom shall I take support for database?
@gpub1 Actually we are not generating any kind of token, can you please elaborate more on approach you are suggesting. Thanks for supporting me.
It will depend on which database you’re using, my guess is that most of them will have their own support forum/team that you can reach out to and that will be able to help.
As Arlemi mentioned, apart from that you can reach your DB admin/support team on this ask them about the DB behavior of conflict, which i think is due to security.
Another approach i would suggest count how many times does your multiple request works (201) with that key combination. Restrict till that iteration and restart again
hope this helps.