0

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.

https://management.azure.com/subscriptions/xxxx-xxxx-xxxx/resourceGroups/xxxx-xxxx-xxxx?api-version=2021-04-01

Can any one help me out what's wrong with this API.

Thank you.

2

1 Answer 1

0

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

BEFORE ADDING TAG:- enter image description here

ADDING BELOW IN PARAMS: enter image description here

CHANGE BELOW IN AUTHORIZATION:- enter image description here

In body add properties in below json format

{
"operation": "merge",
  "properties": {
    "tags": {
      "ajtagsss": "newtagtestsss"
     
    }
  }
}

enter image description here

After that send request which will return 200.

enter image description here

AFTER ADDING TAGS TO RESOURCE GROUP:-

enter image description here

For more information please refer this SO THREAD as suggested by @MadhurajVadde-MT in comment.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.