Is there still no way of querying stories with attachments?
I tried using the WSAPI documentation for this and it doesn't work.
Is there a reason why? I was assuming that if something was in the WSAPI doc then it can be queried upon (unless it mentions so in the document itself for the field).
How do I identify such fields then?
You can use WSAPI to find User Stories that have attachments.
Here is a query that you can apply to the Custom List app that will filter only user stories that have attachments and are in the backlog.
The part of: (Attachments.ObjectID != null) is how you filter for attachments. You can also use: (Attachments.ObjectID > 0)
Let us know if this helped.
Ahh! Thank you Sagi!
I did not think of ObjectID.
Also, how do I extract the attachment name and attachment descriptions?
Will it be Attachments.Name and Attachments.Description ?
You won't be able to make a reference such as: Attachments.Name or Attachments.Description. The reason is that the 'Attachments' is a collection object. That object doesn't have a 'Name' or a 'Description'. These fields belong to the each of the internal items inside the collection. You will need to extract each actual Attachment item from the collection, then make a reference to the Name or Description field.
So, you'll need to call the Attachments _ref field which holds the URL of that collection. This will return the collection object along with total result count , then you can iterate or further filter on the items inside.
Okay, I think I understand what you mean. So if I have to extract information about all attachments from a story (attachment name, description etc), how do I do it?
How do I do the Attachments_ref field?
It will be more difficult to get to the individual attachment by the collection, unless you use the SDK or some ToolKit (like Java or .NET) that will allow you to examine and iterate over the collection objects.
So my suggestion is this:
1. You can use the query I sent you earlier to find all user stories in backlog that have attachments.
2. Then, for any such user story (which you know the Name) you can use the Attachment endpoint and filter by the Artifact field such as: (Artifact.Name = "Your User Story Name") . This will return all individual attachments of that particular user story where you can fetch the Name, Description, ContentType etc..
Check out the 'Attachment' endpoint and see it's field called: Artifact. That will probably be the easiest way to get it all done.
So, in step 1 you find all your user stories, then one-by-one you query the Attachment endpoint for each such story and get the info on its attachments.
Let me know if helped.
I tired this and was able to attach said custom app without error. But this is not working for me... it shows some random numbers as result (not the story id's etc). Is there any other dependancy of this app? like browser etc?
Retrieving data ...