How can we update or add new tags to the resource group using API. I have tried the below API in Postman with PUT method. But its removing the first two tags and adding new tags.
Can any one help me out what's wrong with this API.
Thank you.
How can we update or add new tags to the resource group using API. I have tried the below API in Postman with PUT method. But its removing the first two tags and adding new tags.
Can any one help me out what's wrong with this API.
Thank you.
To resolve the above issue you can try the below solution with PATCH method.
Basically PUT is for checking if resource is exists then update , else create new resource. PATCH is always for update a resource .
When we try with PUT method facing the same which will remove the existing tag and adding the new tag.
Try the below API with PATCH method and add in body as shown below:-
https://management.azure.com//subscriptions/subscriptionid/resourceGroups/rgname/providers/Microsoft.Resources/tags/default?api-version=2021-04-01
CHANGE BELOW IN AUTHORIZATION:-

In body add properties in below json format
{
"operation": "merge",
"properties": {
"tags": {
"ajtagsss": "newtagtestsss"
}
}
}
After that send request which will return 200.
AFTER ADDING TAGS TO RESOURCE GROUP:-
For more information please refer this SO THREAD as suggested by @MadhurajVadde-MT in comment.