1

This is a follow-on question from "Adding a VersionOne expression using the REST API"...

I am trying to add an Expression (comment) to a story in VersionOne. I can now do this (with some help - see original post), but I have a related question:

In VersionOne, each Story has a Number (e.g. "B-01123") and a Name (e.g. "Fix ProcVars REST functionality"). It can be queried on these things using e.g:

<Server Base URI>/rest-1.v1/Data/Story?sel=Name,Number&where=Number='B-01123'

However, internally, all VersionOne assets have an OID - for instance, the above story might have an OID of "Story:2017". This is the unique asset identifier.

It appears that to add an Expression or a Link to a Story, you need to know the OID of the Story, because when adding something, you need to typically include the following the in the POSTed XML:

<Relation name="Asset" act="set">
    <Asset href="<Server Base URI>/rest-1.v1/Data/Story/2017" idref="Story:2017" />
</Relation>

Of course, you can perform a query (like the above) to get an XML response which includes the OID, and then parse it out from the XML and pass it in a new request. However, this is a two-part task, and is a huge hassle.

Is it possible to e.g. add a Link or an Expression to a Story where all you know is the Story Number (the user-visible bit)?

Community
  • 1
  • 1
roryhewitt
  • 4,097
  • 3
  • 27
  • 33

1 Answers1

0

Is it possible to e.g. add a Link or an Expression to a Story where all you know is the Story Number (the user-visible bit)?

No. The Number attribute is merely a text label. It has an association to an OID indirectly by virtue of the fact that it is a part of an Asset that has an OID but it can't be substituted for an OID. An OID represents an official system Asset. Any time you decide to update,add or delete any asset in VersionOne, you have no choice but to reference an Asset's official "OID".

Since Number is a read-only, unique field, I guess it might be tempting to think that you could use that as a reference. Just create a method that takes a Number like this and parse the output as you have been doing.

string GetOid(string Number)
{

    string URL="rest-1.v1//Data//PrimaryWorkitem?sel=ID,Number&where=Number=\'"+Number+"\'");
    var response = POST(URL); 
.
.
.  //Xml plumbing to extract OID from response
.
.
.  return OID;
}


GetOID("Defect","D-01001");

This will work for Defects, Stories or TestSets. If you use the keyword Workitem instead, in addition to the PrimaryWorkitems, you can access Themes, Epics, Tests, Tasks

FYI: There is an existing VersionOne SDK that can do all of the xml plumbing.

Mark Irvin
  • 830
  • 1
  • 6
  • 16
  • I'm marking this as the solution, even though it doesn't help me :( Unfortunately, this is being done as a Perl script, and the hope was that it could be something simple to achieve. I probably can go more complex and get the response from a query and parse out the OID, but if it's not a really simple exercise, we'll probably go a different route. – roryhewitt Jun 16 '14 at 18:26