How to Get User Story for a Task Using Visual Studio REST API - api

I'm trying to use Visual Studio's API to gather information about work items for a Visual Studio Online team into an Excel doc. I can get the work items' information as well as whether each item is a User Story, Task, or Bug by using API calls to extract its json fields. However, I can't figure out how to get the "parent" User Story for a Task or a Bug. E.g. a task will be within a User Story section on my work board, but I don't see any field that corresponds to that story within the work item's possible json keys.
The keys I can see for a work item are these:
['System.AuthorizedDate',
'System.WorkItemType',
'System.Title',
'System.IterationLevel1',
'System.IterationLevel2',
'System.History',
'System.AreaId',
'System.NodeName',
'Microsoft.VSTS.Common.ActivatedDate',
'System.IterationId',
'System.IterationPath',
'System.PersonId',
'System.AssignedTo',
'System.AuthorizedAs',
'System.Id',
'System.Reason',
'System.CreatedBy',
'Microsoft.VSTS.Common.StateChangeDate',
'Microsoft.VSTS.Common.Priority',
'System.Watermark',
'Microsoft.VSTS.Common.ActivatedBy',
'System.AreaPath',
'System.State',
'System.ChangedDate',
'System.AreaLevel1',
'System.CreatedDate',
'System.TeamProject',
'System.Rev',
'System.ChangedBy',
'System.RevisedDate']
None of their values corresponds to anything that matches a User Story's text or provides a url to a User Story's json.
Does anyone know how to get parent (User Story) of a task or a bug using API calls?

Add "expand=all" or "expand=relations" in your request url will show the linked work items and "System.LinkTypes.Hierarchy-Reverse" type point to the Parent work item.
Example:
https://xxxxx.visualstudio.com/defaultcollection/_apis/wit/workitems?ids=47&$expand=relations&api-version=1.0

Related

How to Get All Tasks from a Story Using DevOps API

I'm trying to get all Tasks from a Story with the DevOps API but I only found a relation expand command which is not that what I want.
So how can I "expand" a Story to see all Tasks?
API REQ: https://----/----/----/_apis/wit/workitems/ID?api-version=5.1
With that I only get like the name, desc, state, reason, assignedto and so on.
Check with the related REST API and Azure CLI, it seems that currently we have no easy way to get the list of Tasks that have been linked to a User Story.
You can execute the API "Work Items - Get Work Item" and get the list of work items that have linked to the specified User Story from the Response body of this API.
GET https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/{id}?$expand={$expand}&api-version=6.1-preview.3
In the list you can get the URL of each linked work item. You can get the detailed information of each work item via sending request to the URL. From the detailed information, you can get the work item type of each item.

How to get the list of all User stories including child stories using /slm/webservice/v2.0/hierarchicalrequirement API

I am using this rally API to get the list of all the stories:
https://rally-n.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement?query=(Project.Name="My_Parent_Project")&order=OrderString
My_Parent_Project actually do not have any user stories, but its children projects (my_child_1 and my_child_2) has user stories.
Is there any specific field, which I can mention to get all the user stories including child projects.
I can see Rally UI has option to get the data from Child project. So I believe there must be an option to get this data using above API. (They use projectScopeUp=false&setScopedDown=true which doesn't seems to be working with
"hierarchicalrequirement" API.
You're really close.
It seems like you've already found the project scoping docs:
https://rally1.rallydev.com/slm/doc/webservice/projectscope.jsp
I think if you just swap your (Project.Name = "My_Parent_Project") query to instead use the project=/project/12345 query string parameter and include projectScopeDown=true you should be all set.

How do I programmatically create a new TFS Task?

I'm looking to create a Visual Basic Windows Form Application which has similar input fields to the new task creation page on the browser version of TFS. the idea is to automate some of the form filling saving up on time (is, calculating time estimates based on dates taking into account work hours and weekends, automatically filling out fields)
When i search Google however i keep getting results like customizing TFS or how to make a new task using the interface, however what i am looking for is what classes i'm supposed to use to create a new task and then to save it or search current existing tasks.
So How do I programmatically create a new TFS Task if it's possible? (it should be, Visual Basic and TFS are both Microsoft)
There is an example on MSDN. See this page: "Create a Work Item By Using the Client Object Model for Team Foundation".
The core of the example is:
// Create the work item.
WorkItem userStory = new WorkItem(workItemType)
{
// The title is generally the only required field that doesn’t have a default value.
// You must set it, or you can’t save the work item. If you’re working with another
// type of work item, there may be other fields that you’ll have to set.
Title = "Recently ordered menu",
Description = "As a return customer, I want to see items that I've recently ordered."
};
// Save the new user story.
userStory.Save();

Possible to fetch full hierarchical requirements in single portfolio item web service call?

I'm trying to aggregate some information about the kanban states of my user stories. If query a PifTeam item, I get a summarized collection of UserStories associated with it.
Example query:
https://rally1.rallydev.com/slm/webservice/1.40/portfolioitem/pifteam/99999999999.js
However I then have to run a loop on the UserStories collection, individually querying each one to get at the information I need. This potentially results in a lot of web service calls.
Is there a way to return the full hierarchical requirement information in the original pifteam query so that there is only one webservice call which returns all sub-objects? I read the webservice api and was trying to play with the fetch parameter but had no success.
This functionality will be disabled in WSAPI 2.0 but will continue to be available in the 1.x versions. That said, you should be able to use a fetch the fields on story that you need like this:
/pifteam/9999.js?fetch=UserStories,FormattedID,Name,PlanEstimate,KanbanState
Fetch will hydrate the fields specified on sub objects even if the root object type doesn't have those fields. So by fetching UserStories the returned collection will populated with stories, each having the FormattedID, Name, PlanEstimate and KanbanState fields included.
There is no way to do it from Rally's standard Web Services API (WSAPI) but you can from the new Lookback API (LBAPI). The query would look something like this:
https://rally1.rallydev.com/analytics/v2.0/service/rally/workspace/<ObjectID_for_Workspace>/artifact/snapshot/query.js?find={__At:"current",_TypeHierarchy:"HierarchicalRequirement",Children:null,_ItemHierarchy:<ObjectID_for_PortfolioItem>}&fields=["Name"]
Fill in the ObjectIDs for your Workspace and PortfolioItem. The _ItemHierarchy field will cross work item type boundaries and goes all the way from PortfolioItems down through the Story hierarchy down to Defects and even Tasks, so I added _TypeHierarchy:"HierarchicalRequirement" to limit it to Stories. I have specified Children:null which means you'll only get back leaf Stories. The __At:"current" clause get's the current tree and values. Remember, it's the "Lookback" API, so you can retrieve the state of the object at any moment in history. __At:"current" says to get the current values and tree.
Note, the LBAPI is delayed from current values in the system by anywhere from seconds to minutes. Typically it's about 30 seconds behind. You can see how far behind it is by checking the ETLDate field in the response.
Details about the LBAPI can be found here. Note, that the LBAPI is available in preview now for almost all Rally customers. There are still a number of customers where it is not yet turned on. The best way to tell if it's working for your subscription is to try the query.

Facebook Event - guest list & posting settings

I'm trying to add a "create Facebook event" functionality to my application that uses Graph API. I have read their documentation and I am able to create an event with basic informations, like name, description, time, place etc.
However, the documentation doesn't mention two fields I'm especially interested in: Show the guest list on the event page and Non-admins can write on the wall.
I have investigated the data sent to Facebook while creating new event on site and it seems like these two fields are named respectively guest_list and connections_can_post. Unfortunately, adding these two fields to my request has no effect. I have tried different combinations, but they seem to be ignored.
Is it possible to set those two fields through API?
I don't believe either of those fields can currently be set via the API