WSAPI: Create an artifact with a tag using

Document ID : KB000092716
Last Modified Date : 21/04/2018
Show Technical Document Details
Introduction:
Can we use the WSAPI to create an artifact with a tag?
Background:
Creating an artifact and associating it with a tag is possible using WSAPI. This document demonstrates how to do that for a Defect. Similarly it can be done with any other artifact.
Instructions:
In order to create an artifact with a tag , you will need to have a tag already created. 

Step 1: find the ObjectID of your tag
You should use the Query operation using your tag's Name and value. In this example we used the WSAPI help pages. You can use any other utility that lets you make REST calls to this endpoint.
User-added image

The result will return the Tag object. You will need to find the ObjectID. This screen shot is the returned screen of our former query where the ObjectID is highlighted.

User-added image

Step 2: Create your artifact and associate it with the tag.
Make a 'create' call to the endpoint of your artifact. The JSON body can include an array called: "Tags". Use that array to include all references to the tags you are associating with this artifact. In this example we use the reference to our tag , using the _ref property.
Here we create a Defect , but a similar idea is for all other artifacts.
User-added image

Check out your result. Below you see a 200 OK return code and the JSON returned contents. See the _refObjectName that holds the name of the artifact you created.
User-added image

Step 3:  Let's confirm in Rally that the artifact was created and associated with the tag.
User-added image

At bottom right of next screen you can see the tag that's associated with this artifact. "MyTag" indeed was the tag we used in Step 1 to associate with this artifact.

User-added image