Skip to content

Commit 919c170

Browse files
author
Justin Marks (MSFT)
committed
Fix ClientLibrary Sample
1 parent fa30a31 commit 919c170

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

ClientLibraryConsoleAppSample/Program.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,29 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
using Microsoft.TeamFoundation.WorkItemTracking.WebApi;
1+
using Microsoft.TeamFoundation.WorkItemTracking.WebApi;
72
using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models;
83
using Microsoft.VisualStudio.Services.Client;
94
using Microsoft.VisualStudio.Services.Common;
105
using Microsoft.VisualStudio.Services.WebApi;
6+
using System;
7+
using System.Linq;
118

129
namespace ClientLibraryConsoleAppSample
1310
{
1411
class Program
1512
{
1613
//============= Config [Edit these with your settings] =====================
17-
internal const string vstsCollectionUrl = "http://myaccount.visualstudio.com"; //change to the URL of your VSTS account
14+
internal const string vstsCollectionUrl = "https://myaccount.visualstudio.com"; //change to the URL of your VSTS account; NOTE: This must use HTTPS
1815
// internal const string vstsCollectioUrl = "http://myserver:8080/tfs/DefaultCollection" alternate URL for a TFS collection
1916
//==========================================================================
2017

2118
//Console application to execute a user defined work item query
2219
static void Main(string[] args)
2320
{
24-
//Prompt user for credential for collection specified above
25-
VssCredentials cred = new VssClientCredentials(false);
26-
cred.PromptType = CredentialPromptType.PromptIfNeeded;
27-
VssConnection connection = new VssConnection(new Uri(vstsCollectionUrl), cred);
21+
//Prompt user for credential
22+
VssConnection connection = new VssConnection(new Uri(vstsCollectionUrl), new VssClientCredentials());
2823

2924
//create http client and query for resutls
3025
WorkItemTrackingHttpClient witClient = connection.GetClient<WorkItemTrackingHttpClient>();
31-
Wiql query = new Wiql() { Query = "Select [State], [Title] from WorkItems where [Work Item Type] = 'Bug' And [Tags] Contains 'findMe'" };
26+
Wiql query = new Wiql() { Query = "SELECT [Id], [Title], [State] FROM workitems WHERE [Work Item Type] = 'Bug' AND [Assigned To] = @Me" };
3227
WorkItemQueryResult queryResults = witClient.QueryByWiqlAsync(query).Result;
3328

3429
//Display reults in console

0 commit comments

Comments
 (0)