Working with version attributes through the 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:
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.
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.
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?
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.
Bob W.
· 1 |
|
Friday, April 1, 2011, 1:31:30 AM |