I know what both PUT and POST method is and use for, but I wanted to know a few things in my current scenarios.
Just before that, brief out about my API:
-
POST endpoint for insert new records and in request body has existing record client will get the duplicate and ask for do the PUT as record already exists.
-
PUT for updating my existing records and if not existing record is coming on the body client will get the message to use POST as the record is new one.
-
GET for comment select operations
Our use case -
we wanted to automate this API interaction, I used PostMan for all my development/testing part.
Now, I am writing the Azure DevOps pipeline to automate the insert and update stuff for this I would get the input from one repository which the user will update with required input, the input will be in the JSON format. I will have one bash script for checkout the inputs repository and I will loop through the all input JSONs and will those API.
My question is - as I have a separate endpoint for insert and update... so how I can automate it as from the pipeline? I would gonna call one POST/PUT for the given JSON input.
Should I have to write PUT call within the POST method when I find data having already existed and same in case of PUT if an incoming record is new I should have to call POST method instead.
I think this will violate the separation of concern principle for any of the method.
let me know what is the best way to deal this condition with best practices.
Aucun commentaire:
Enregistrer un commentaire