Reputation: 17
I am new to this TFS thing. I am aware of the API to use for Recent CheckIn which is Changeset API. I am also aware that other post about Recent CheckIn, but they don't fulfil what i want. Since TFS has disabled this Recent CheckIn webpart, i need to rebuild this webpart. So in that case , i need to query all the recent checkin with the Id,comment attribute, shown in below.
Anyone can guide me along?
Your help is appreciated
Upvotes: 0
Views: 172
Reputation: 16048
(If SharePoint webparts supports that) You may try to use net libs for rest api: https://learn.microsoft.com/en-us/vsts/integrate/get-started/client-libraries/samples
This is example of top 10 chekins:
public IEnumerable<TfvcChangesetRef> ListChangesets()
{
VssConnection connection = this.Context.Connection;
TfvcHttpClient tfvcClient = connection.GetClient<TfvcHttpClient>();
IEnumerable<TfvcChangesetRef> changesets = tfvcClient.GetChangesetsAsync(top: 10).Result;
foreach (TfvcChangesetRef changeset in changesets)
{
Console.WriteLine("{0} by {1}: {2}", changeset.ChangesetId, changeset.Author.DisplayName, changeset.Comment ?? "<no comment>");
}
return changesets;
}
Full example here: https://github.com/Microsoft/vsts-dotnet-samples/blob/master/ClientLibrary/Snippets/Microsoft.TeamServices.Samples.Client/Tfvc/ChangesetsSample.cs
Upvotes: 0
Reputation: 31043
Results of Changeset API are sorted by ID in descending order by default. And there is a parameter $top
which return the maximum number of results you defined.
So basically, you only need to add $top
parameter, which will return recent checkins you want. The following example will return the most recent 3 checkins:
GET https://{instance}/DefaultCollection/_apis/tfvc/changesets?$top=3&api-version={version}
After running this api, you'll get a JSON file which contains all information of the checkins, then, you need to parse the information in this json file to a table.
Upvotes: 0