OData Service for Team Foundation Server V2

OData Service for Team Foundation Server V2

The OData Service for Team Foundation Server V2 is a sample that exposes select data and functionality from Team Foundation Server using the client object model. It makes it easier to build applications for a multitude of devices which consume or manipulate data stored in Team Foundation Server 2010, 2012, or CodePlex.

The purpose of this wiki page is to document known issues, provide a FAQ, and perhaps discuss and link to samples that show how to consume the OData Service on various clients.

For more information about the service and code, click here.

Have feedback or bug reports? Please send to TFSOData@Microsoft.com and include as much pertinent detail as you can.




Changelog


Version 2.3.0:
  • Fixed bug/configuration issue where incorrect data could be returned when multiple, authenticated requests made identical queries
  • Fixed bug where work item queries were not allowed to contain multiple ChangedDate or CreatedDate filter expressions (it is allowed now)
Version 2.2.0 Beta:
  • Can now be configured to work against Team Foundation Service (tfs.visualstudio.com)
  • Work item queries performance improvements (for queries by project collection, project, and query)
  • IterationPath is now available (mirrors AreaPath functionality for now)
  • Simple TFS single-user lookup. Can specify a user name, see updated landing page for details on performing queries. For example, this enables you get the display name for the email address used by end-user when providing basic auth creds
  • All startup tasks only run in Azure environment (no longer the emulator as well)
  • Fixed bug where work item queries for project (and build) loses scope when filters are applied
  • Fixed bugs where work item updates were not working for all properties
  • Fixed bugs where filtering was not working as expected when multiple filters were applied
  • Fixed bug where ‘substringof’ filters were not being interpreted correctly (e.g. ‘substringof(‘asdf’,Title)’ should be interpreted as ‘substringof(‘asdf’,Title) eq true’)
  • Configured default solution to utilize the Azure .wadcfg way of configuring diagnostics

Version 2.1.0 Beta:

  • Fixed bug in RequestWorkItemsByProject where incorrect WIQL was being generated in the case where more than one filter clause was provided. This corresponds to queries such as:
  • /DefaultCollection/Projects(‘prjName’)/WorkItems?$filter=Type eq ‘Bug’ or substringof(‘bug’,State) eq true

Version 2.0.0 Beta:

  • Added WorkItems(X)/Links to API to return links for specific work item
  • Added additional WorkItem fields (Blocked, OriginalEstimate, RemainingWork, StoryPoints, BacklogPriority, BusinessValue, Effort, Size, CompletedWork, AttachedFileCount, HyperLinkCount, RelatedLinkCount)
  • Fixed bug where larger uploads would fail (configuration change)
  • Fixed bug where larger uploads would fail to an HTTPS endpoint (service configuration)
  • Fixed bug where $value command was not returning Attachments
  • Session state turned off to avoid intermittent bug
  • Changed to buffered output from WCF service (not chunked)
  • Improvements in some exception handling and logging


Known Issues & Important Notes


The only breaking change from V1 to V2 is that the work item properties have been modified. Some property names have been changed, types changed, and additional properties added in.

When adding a service reference to the OData endpoint in Visual Studio, the generated proxy code creates WorkItem.CreateWorkItem method that has all possible numeric and DateTime properties listed (even though not all of them should be required). For an example of how to deal with this, you can see the included console application. Or simply don't use this method and create your own WorkItem and fill in necessary properties.

If you suddenly start to experience inexplicable problems (I know this sounds vague) with a deployment, you may want to rule out the possibility of the TFS object model cache being the root cause. Of course, this isn't easy to do on a running web server, but if you can take it offline temporarily try deleting the cache files. The cache files to be deleted are sometimes in ProgramData\Microsoft Team Foundation\4.0\Cache, sometimes in the user AppData\Local\Microsoft\Team Foundation\4.0\Cache. The cache will automatically be rebuilt as needed.


FAQ


Q: What can I do to increase performance of [insert functionality here]?
A: 1) Use dynamic content compression in IIS, if possible, as some queries can return a lot of data. 2) See if there is a more focused query that you can use to get the data you need and ignore what you don't. For example, if you don't want all Build fields retuned (such as Warnings or Errors), use a select statement and do not include them. 3) Other queries may simply need additional performance work done in the OData service code itself, so you'll need to dig into the codebase to make the necessary changes.

Q: How do I add the Basic authentication header to requests to the OData Service?
A: From a .NET client application, you can do something like:
    
var proxy = new TFSData(new Uri("https://codeplexodata.cloudapp.net/"));
proxy.SendingRequest += (s, e) =>
{
   var credentials = string.Format(CultureInfo.InvariantCulture, @"{0}\{1}:{2}",
                         "sampleTfsDomain", "sampleTfsUser", "sampleTfsPassword");
 
   e.RequestHeaders.Add("Authorization", "Basic " + Convert.ToBase64String(new ASCIIEncoding().GetBytes(credentials)));
}

Q: How do I deal with a self-signed certificate in client code?
A: Use the ServerCertificateValidationCallback if it is available to you. For example:
    
System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => { return true; };

Q: I'm trying to run the web project from the ODataTFS solution and I get back HTTP 404 errors when trying to connect to the OData endpoint using HTTP. For example, http://localhost:10042/DefaultCollection. What's wrong?
A: The WCF service is configured with a single binding that requires transport security to be used, therefore it will not work with HTTP by default. You can change the binding to allow use of HTTP by setting security mode to "None" (or by creating an additional binding to allow use of both), but this is a security risk as the service makes use of Basic authentication. To enable a smoother F5 debugging experience, single-click on the ODataTFS.Web project node in Solution Explorer, open the Properties window (F4), copy the SSL URL, and paste the SSL URL as the "Start URL" in the ODataTFS.Web project properties Web tab (Project | ODataTFS.Web Properties... from main menu). The start action settings are stored in user files, therefore the start action of "Current Page" is the default when loading up the extracted sample code.

Q: How do I add in additional features to the service?
A: This depends on what you are trying to accomplish. If you want to add in functionality that involves an understanding the OData protocol in general, check out http://www.odata.org/. To get more into the specifics used by the OData Service, check out the WCF Data Services Toolkit. The Toolkit, and therefore the OData Service itself, uses WCF Data Services to deliver OData specific functionality. The article here also provides a good overview of the Toolkit: http://lostintangent.com/post/3189655590/you-want-to-wrap-odata-around-what.

Q: How do I find my CodePlex project collection and credentials to use?
A: Sign in at Http://www.codeplex.com/ to your account. Navigate to your project page, click the Source Code tab, and then click the Connect tab to show the project collection, username, and password.

Q: Are OData Service queries case-sensitive?
A: Yes. For example, to query Projects you need 'P' to be capitalized.

Q: What OData parameters are NOT supported?
A: $inlinecount and $expand are not currently supported.


See Also


Sort by: Published Date | Most Recent | Most Useful
Comments
  • Nice Article..!!

    Overall what is ideal scenario for this OData implementation?

  • hi!

    i am trying to Create a infopath form published on SP365, this form is going to have dropdownlist populated by TFS REST Services. wanna have an workflow created by SPD which is going to triggered by submitting the infopath webform and do some crud operation to TFS, the problem that i am facing is, how to Authentication/Authorization against the TFS SERVER från sp workflow?.

  • Are you going to support custom fields for WI's?

Page 1 of 1 (3 items)