Gemini Community Support Site

This Gemini community support site can be used to find solutions to product issues. You can log in using Open Id, Google Profile and even Facebook. Feel free to ask a question or browse FAQs and documentation. Product tour videos are also available along with how-to videos demonstrating key Gemini capabilities.




Working with version attributes through the API

usage
api

I'm trying to use the API to set the values of a set of version attributes. Unfortunately, the docs leave me stumbling in the dark. Some of the more pressing questions that come to mind are:

  1. What is the purpose of CreateProjectVersionAttributeValues as compared to CreateProjectVersionAttributeValues? Inside the app, I don't have more than one set of values for a given attribute (I just have one value that I can change at will), so I'm not sure how these differ. In my situation, I have a project, a version, and version attributes declared on the project, and I'm trying to programmatically set the attributes associated with new versions created in the UI.

  2. Do I have to work with these attributes by value, or can I do it by name? I have the same set of attributes on all the projects I'll be working with, so it'll be much less work if I can just work with them by name. The VersionAttributeValueEN structure has both, but I don't know which is required when.

  3. In the API docs, there's a "{1}" included in some of the URLs. In my case, I assume these are supposed to be placeholders for versions IDs, as you'll see in my sample POST below. Is this correct?

  4. Thinking I might be stuck working with IDs rather than names, I used GetProjectAttributes to get the list of values. And, it came back blank, which didn't make sense since the attributes are definitely defined. After a bit of head-scratching, it occurred to me that maybe Gemini was only returning those attributes that had non-blank values, and I verified this by setting one. In my mind, and from the perspective of the application's UI, the attributes always exist on the version, but they may have blank values, and so, I'd expect to see all the attributes returned by this method that's documented to "fetch all" attribute values. In any case, this makes it rather hard to know what the IDs are until values have been set, but if I can't set values without knowing the IDs....

Anyway, so I'm trying to use CreateProjectVersionAttributeValue to accomplish this, but I keep getting back the following error:

The enclosed object does not appear to be a valid CounterSoft.Gemini.Commons.Entity.VersionAttributeValueEN

Here's the request I'm sending:

POST /api/projects.ashx/42/versions/2960/versionattributevalues?format=xml[...] HTTP/1.1
Host: xxxx
Accept: */*
Content-Type: text/xml; charset=iso-8859-1
Content-Length: 296


<VersionAttributeValueEN>
    <State>NoChange</State>
    <ProjectID>42</ProjectID>
    <AttributeID>6</AttributeID>
    <VersionID>2960</VersionID>
    <AttributeName>File Changes</AttributeName>
    <AttributeValue>Hello world, from the API!<AttributeValue>
</VersionAttributeValueEN>

Is this the right approach? If so, what am I doing wrong? I'm particularly wondering about that State element, but the docs don't talk about it all. Alternatively, if this is completely wrong, then what's the correct way to go about doing this?

Details:

  • Gemini 4.0
  • Accessing the API from PHP

On a separate note, the API docs on your site are still for v3.7. Is a 4.0 version (hopefully with more details) coming soon?

Thanks.

··· Very little changes in API from v3.7 and v4.0 - API docs will be migrated over to here very soon.Harvey KandolaFriday, April 01, 2011, 8:18:25 AM
Bob W.
· 1
Bob W.
Replies (7)
helpful
0
not helpful

You are missing the project id from the url: /api/projects.ashx/projects/42/versions/2960/versionattributevalues?format=xml

That should solve your issue.


Saar Cohen
· 5000
Saar Cohen
helpful
0
not helpful

In that case, I'd like to report an error in the docs :-). To wit:


Create Version Attribute Value

REST End-point POST/api/projects.ashx/{projectId}/versions/{1}/versionattributevalues Client API Method ProjectsService.CreateProjectVersionAttributeValue Request Body VersionAttributeValueEN

Creates new Version Attribute Values based upon provided VersionAttributeValueEN object. Returns a VersionAttributeValueEN object that will contain new Attribute Id.


In any case, I tried it with the revised URL (both with and without the extra project ID, which I assume was just a typo), and I get the same result every time. Any other ideas?

BTW, question 1 dealt with CreateProjectVersionAttributeValues versus UpdateProjectVersionAttributeValues, not CreateProjectVersionAttributeValues versus CreateProjectVersionAttributeValues.


Bob W.
· 1
Bob W.
helpful
0
not helpful

Can you please try and add 0001-01-01T00:00:00 to the attribute value XML?

Not sure I understand your 2nd question, "CreateProjectVersionAttributeValues". Can you please point me to the right direction? as both names are the same.


Saar Cohen
· 5000
Saar Cohen
helpful
0
not helpful

Can you please try and add 0001-01-01T00:00:00 to the attribute value XML?

Using a DateCreated element, I assume? It produced the same result, unfortunately; here's the new request:

POST /api/projects.ashx/projects/42/versions/2960/versionattributevalues?format=xml[...] HTTP/1.1
Host: xxxx
Accept: */*
Content-Type: text/xml; charset=iso-8859-1
Content-Length: 347

<VersionAttributeValueEN>
    <DateCreated>0001-01-01T00:00:00</DateCreated>
    <State>NoChange</State>
    <ProjectID>42</ProjectID>
    <AttributeID>6</AttributeID>
    <VersionID>2960</VersionID>
    <AttributeName>File Changes</AttributeName>
    <AttributeValue>Hello world, from the API!<AttributeValue>
</VersionAttributeValueEN>

As for your other question about the names, please see my previous response for clarification... it was just a copy/paste mistake.


Bob W.
· 1
Bob W.
helpful
0
not helpful

Any other ideas for this one?

··· Let us get back to you...Harvey KandolaWednesday, April 06, 2011, 9:49:47 AM

Bob W.
· 1
Bob W.
helpful
0
not helpful
ANSWER

Argh! I found the problem: take a gander at the closing tag of the last element in the block....

Going on, and for the benefit of other forum visitors, it turns out that AttributeName is not required and is ignored if you include it, which means you need to use AttributeID. Here's what seems to be the minimal XML you need to send over:

<VersionAttributeValueEN>
    <ProjectID>12</ProjectID>
    <VersionID>4121</VersionID>
    <AttributeID>8</AttributeID>
    <AttributeValue>Fusce luctus convallis justo</AttributeValue>
</VersionAttributeValueEN>

Thus, my procedure now is to use GetProjectVersionAttributes to get a list of the attributes, search through them for the one with the name I'm looking for, pull out the ID, and then use that in CreateProjectVersionAttributeValue.

I'm still not at all clear on the role of CreateProjectVersionAttributeValue versus UpdateProjectVersionAttributeValue, which may very be the cause of my next problem. But that's for another post.

Thanks for the help, and sorry for any unintended misdirection.


Bob W.
· 1
Bob W.
helpful
0
not helpful

Glad you got it working!

CreateProjectVersionAttributeValue will create the value for the specific version. UpdateProjectVersionAttributeValue will update the value for the specific version. In other words you should only call CreateProjectVersionAttributeValue once per attribute per version.


Saar Cohen
· 5000
Saar Cohen