Search code examples
versionone

Set Priority while creating a new defect using rest-1.v1


I'm using the Rest API endpoint to create new issues and defects. I'm trying to set the priority of the created things while creating them. Here is the POST XML I'm using.

<?xml version=\"1.0\" encoding=\"UTF-8\"?>
              <Asset href=\"/url/rest-1.v1/New/Defect\">
              <Attribute name=\"Name\" act=\"set\"> $defect_name </Attribute>
              <Attribute name=\"Description\" act=\"set\"> $defect_description </Attribute>
              <Relation act=\"set\" name=\"Priority\">
                  <Asset href=\"/url/rest-1.v1/Data/WorkitemPriority/138\" idref=\"WorkitemPriority:138\" />
              </Relation>
              <Relation name=\"Scope\" act=\"set\">
                  <Asset href=\"/url/rest-1.v1/Data/Scope/$scope_number\" idref=\"Scope:$scope_number\" />
              </Relation>
              </Asset>

and here is the response I receive from the server:

<?xml version="1.0" encoding="UTF-8"?><Asset href="/url/rest-1.v1/Data/Defect/23574/79418" id="Defect:23574:79418"><Attribute name="Name">name</Attribute><Attribute name="Description">description</Attribute><Relation name="Scope"><Asset href="/url/rest-1.v1/Data/Scope/23544" idref="Scope:23544" /></Relation></Asset>

As you can see, the defect is created, but the priority hasn't been set.

Any help or guidance is appreciated.


Solution

  • Here is a simplified working example

    <Asset>
        <Attribute name="Name" act="set">$defect_name</Attribute>
        <Relation name="Scope" act="set">
            <Asset idref="Scope:$scope_number" />
        </Relation>
      <Relation name="Priority" act="set">
            <Asset idref="WorkitemPriority:138" />
        </Relation>
    </Asset>