Webservice TFS Online Preview - c#

i want to access my team foundation server (online preview) webservice by c# code. My problem is to find the right address to connect the webservice ("http://XXX.tfspreview.com" is not the right address).
Does anybody know this address or has some information?
Search on the microsoft homepage got no results.
Thanks!

Here's a thread on this very subject
http://social.msdn.microsoft.com/Forums/en-US/TFService/thread/a56269d8-7840-4d48-b77a-5aaf1976a2a6/

You can add this namespaces
using Microsoft.TeamFoundation.Build.Client;
using Microsoft.TeamFoundation.Client;
Sample (Service Locator TfsTeamProjectCollection )
TfsTeamProjectCollection teamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://tfsURI"));
var service = (YourTypeOfService)teamProjectCollection.GetService(typeof(YourTypeOfService));

Related

Accessing a local instance of the bot framework using DirectLine

I have a bot (basically a clone of the echo bot) and I'm running the service locally. Is it possible to use the Direct Line API to access it (I'm using the NuGet package: Microsoft.Bot.Connector.DirectLine), and I'm trying to access it like this:
DirectLineClient client = new DirectLineClient();
client.BaseUri = new Uri($"http://localhost:3978/api/messages");
var conversation = await client.Conversations.StartConversationAsync().ConfigureAwait(false);
However, conversation is always null. Is it possible to connect to the service locally, or does it have to be deployed to Azure? If the former, then what could I be doing wrong?
Any help would be appreciated.
The Offline-directline package is a way to set up a node server and use directline/webchat to connect to it as if it were a azure endpoint.
You're basically going to follow the usage instructions as they're laid out:
1) Install offline-directline (OD) package
2) Create the OD server using node
3) Run your bot
4) Connect to your bot through a custom webchat that looks to the OD server from step 2 instead of localhost or an azure endpoint

Custom TFS server plugin throws exception TF30063

I've been writing a custom TFS 2013 server plugin for my company that automatically creates tasks whenever a new bug or product backlog item is created. While debugging I can see it detecting the new work item, but when it tries connect to the TfsTeamProjectCollection it throws TF30063 exception saying I'm not allowed to access the server. What baffles me is, in an attempt to see if the code after that worked, I made a simple client-side form application with the exact same code to connect to the server and it worked flawlessly.
The code I'm using to connect with is:
string tfsUri = string.Empty;
tfsUri = #"http://companytfsserver:8080/tfs/defaultcollection";
TfsTeamProjectCollection tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(tfsUri));
tfs.EnsureAuthenticated();
I've also tried manually setting the credentials, but no luck. Also, if it helps, I used this as my guide: http://geekswithblogs.net/BobHardister/archive/2012/10/08/automatically-create-bug-resolution-task-using-the-tfs-2010-api.aspx
I read through a ton of documentation of people getting the same exception, but none of what I found seemed relevant to this particular situation, so any help would be greatly appreciated!
*Update: After more digging and testing, it's possible it may have something to do with our application tier. I'll have to wait for the IT guy that's familiar with that particular system to get back from a conference (Monday, I think), but I'll update once I find out for sure.
**Update: I finally figured it out and I can't believe how simple it was. It turns out the URI that's used to connect via client app does not work when it's used in an app tier server plugin. Instead, it has to be localhost:8080/tfs/defaultcollection. Makes perfect sense to me now, but it never even crossed my mind before.
Just as jessehouwing says, since you are using collection uri "http://companytfsserver:8080/tfs/defaultcollection" You must have permissions on the Prioject(collection) with your account and TFS service account.
// Connect to TFS Work Item Store
ICredentials networkCredential = new NetworkCredential(tfsUsername, tfsPassword, domain);
Uri tfsUri = new Uri(#"http://my-server:8080/tfs/DefaultCollection");
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(tfsUri, networkCredential);
WorkItemStore witStore = new WorkItemStore(tfs);

authentication failed while connecting to tfs using tfs api

I am facing a strange issue.I want to connect tfs server using tfs api programmitcally.
Even after giving proper authentcaion crediatials it is failing.But if I do it manually by typing tfs server name in browser its got connected.
code:
TeamFoundationServer tfs = new TeamFoundationServer(new Uri("http://10.112.205.145:8080/tfs"), new NetworkCredential(#"usrname", "pwd", "domain"));
tfs.EnsureAuthenticated()
Please suggest.
A simple way to do this is to add the "Syetem.Net" namespace to your code and then use the "CredentialCache" object. Using "DefaultCredentials" will Authenticate with the credentials of the active user.
// connect to the collection
using (TfsTeamProjectCollection teamProjectCollection = new TfsTeamProjectCollection("http://server:8080/tfs/DefaultCollection", CredentialCache.DefaultCredentials))
{
//Do Stuff here
}
Have you tried doing it this way..
TfsTeamProjectCollection collection = new TfsTeamProjectCollection(
new Uri(http://server:8080/tfs/DefaultCollection,
new System.Net.NetworkCredential("domain_name\\user_name", "pwd"));
collection.EnsureAuthenticated();
For your problem, normally you get an error like:
Possible reasons for failure include:
- The name, port number, or protocol for the Team Foundation Server is incorrect.
- The Team Foundation Server is offline.
- The password has expired or is incorrect.
The root cause of your problem is that the URI should be ended up with the collection name. So the fix would be, to change "http://10.112.205.145:8080/tfs" to "http://10.112.205.145:8080/tfs/%YourCollectionName%", then it will work! :-)

Accessing Information of the Team Foundation Server via Web Services

I want to Access Information of Builds of Team Projects to use them in other Applications of our Company.
What I need is requesting all Builds for a Team Projekt.
I need Information like:
- the UNC Path the Outlut was copied to
- the Name
- Date of Build
- who started ór triggered the Build (if possible)
I did not find any discription how the Access Information on TFS via Web Services. What I learned is that TFS has a Service Interface.
I hope anyone can give me a litte hint how to reach my goal. If anyone has some sample code I surely would be delighted :-)
Would something like that be helpful:
using System;
using Microsoft.TeamFoundation.Build.Client;
using Microsoft.TeamFoundation.Client;
namespace BuildDetails
{
class Program
{
static void Main()
{
TfsTeamProjectCollection teamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://tfsURI"));
var buildService = (IBuildServer)teamProjectCollection.GetService(typeof(IBuildServer));
IBuildDefinition buildDefinition = buildService.GetBuildDefinition("TeamProjectName", "BuildDefinitionName");
IBuildDetail[] buildDetails = buildService.QueryBuilds(buildDefinition);
foreach (var buildDetail in buildDetails)
{
IBuildInformation buildInformation = buildDetail.Information;
Console.Write(buildDetail.BuildNumber+"\t");
Console.Write(buildDefinition.Name+"\t");
Console.Write(buildDetail.Status+"\t");
Console.Write(buildDetail.StartTime+"\t");
Console.WriteLine((buildDetail.FinishTime - buildDetail.StartTime).Minutes);
}
}
}
}
This is just a standard usage of the TFS-SDK, and I think it provides with the info you 're looking for.
I suggest using wrapper for the wrapper to access to TFS since it's much easier and may be enough for what you need.
If not, I suggest using TFS SDK.
If you still want to go lower, then please read this SO.

RegisteredTfsConnections.GetProjectCollection returns null on test server, but not on dev server

See topic. Everything works fine on my devmachine where VStudio2010 are installed.
But not on a clean test server (The setup project includes all used TFS assemblies).
The docs http://msdn.microsoft.com/en-us/library/ff735997.aspx is not very helpful about the return value:
Null if no match is found.
Should I use another method to get a TFS connection? I'm just trying to list and download some files from a specific project.
Update
I reverted back to this:
var uri = new Uri("http://myserver/");
var tfs = new TeamFoundationServer(uri);
var versionControl = tfs.GetService<VersionControlServer>();
Which works. But TeamFoundationServer is obsolete. So I would like to know how to do it in the new way.
I use:
var uri = new Uri("http://myserver/");
var server = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(uri);
I had the same issue. The RegisteredTfsConnections.GetProjectCollection() method was not consistently returning collections. This wasn't by user but strangely by computer. My dev box showed all collections and my test box showed none.
In my research I found an MSDN article/solution which may help anyone whom currently wants to get a list of TFS collections on the server.
"Sample Code: Connect to Team Foundation Server" by Allen Clark
It worked for me in Team Foundation Server Object Model v12.
I ran into the same issue today. The reason why I was getting a null return was that some users were using TFS through the web interface and they had not added the server through the Visual Studio plugin for TFS.
The answer from RegisteredTfsConnections.GetProjectCollection I get null exception also worked for this situation.
var tfs = new TfsTeamProjectCollection(new Uri("http://example.com:8080/tfs/DefaultCollection"));
var versionControl = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));

Categories

Resources