I am using this code to get sharedsteps and testcase through testmanagement using TFS OM API.
But how can i query SharedSteps and testcase using TestManagementHttpClient in TFS REST API 2018 , kindly suggest me.
string batchQuery = "SELECT * FROM workitem where Id IN (22233,21425,24512) ORDER BY [Id] desc";
ITestManagementService testManagementService = (ITestManagementService)_teamProjectCollection.GetService(typeof(ITestManagementService));
ITestManagementTeamProject _testManagementProject = testManagementService.GetTeamProject(Name);
List<ISharedStep> sharedStepsWIList = _testManagementProject.SharedSteps.Query(batchQuery).ToList();
List<ITestCase> tfsTestCaseCol = _testManagementProject.TestCases.Query(batchQuery).ToList();
There is no method in TestManagementHttpClient to get test cases and shared steps.
Test Case and Shared Steps are work item types, so you can use the Query method in Microsoft.TeamFoundation.WorkItemTracking.WebApi.WorkItemTrackingHttpClient to get these information.
Related
https://learn.microsoft.com/en-us/rest/api/azure/devops/security/?view=azure-devops-server-rest-5.0
https://learn.microsoft.com/en-us/rest/api/azure/devops/security/access%20control%20entries?view=azure-devops-server-rest-5.0
Hi there, I'm having problems with trying to understand the way to set up permissions using the API in ADO 2019. I can see what the security namespace one API does. I can get bitwise that relates to, for examples, git repos. I can't see how to add permissions to a user or group. e.g. I can't see how to get a bitwise that has multiple permissions, do I just add them together? I can see the API that says how to add ACEs but that doesn't actually tell me how to add permissions really. I'll try to explain.
If I run the API for ACL , I get a pile of info back, one of which is token.
Okay, so surely if I get the GUID for the git repo using the git API to list them, the GUID will match up with the ID's in the token like the namespaces do. Nope.
The examples don't seem to be actual examples. I'm looking for 'If you have a git repo , here's how you would give someone permissions to it' 'here's an example of getting the existing permissions for a group and adding another'.
Instead it's just
'here's a string of guids getting put into the API' without explaining the pieces or what specifically it was doing. I can't seem to relate what's in the GUI for adding perms, to what the security API is bringing back.
Am Azure DevOps on prem so I'm more limited in tool selection. Other people I've asked say they gave up trying to use this. AzureDevops on twitter says I can connect with the team here. I'm asking how to do things with the security API and then I can go write it up and suggest how to update the docs. I'm clearly too thick to figure it out from what's there and I don't seem to be the only one. Thanks
For Azure DevOps Service, you can manage group membership using Graph API. But this api is not available for Azure DevOps Server.
In my opinion, for on-premise TFS/Azure DevOps Server, TFSSecurity command line is easier than TFS API to add permissions for a user or a group in a server-level, collection-level, or project-level group. You may consider using TFSSecurity command line:
https://learn.microsoft.com/en-us/azure/devops/server/command-line/tfssecurity-cmd?view=azure-devops-2019
You may also check the following code to get the permissions:
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Server;
using Microsoft.TeamFoundation.VersionControl.Client;
using Microsoft.TeamFoundation.Framework.Client;
namespace API
{
class Program
{
static void Main(string[] args)
{
string project = "http://xxx.xxx.xxx.xxx:8080/tfs";
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri(project));
var tps = tpc.GetService<VersionControlServer>();
var ttt = tps.GetTeamProject("ProjectName");
ISecurityService securityService = tpc.GetService<ISecurityService>();
System.Collections.ObjectModel.ReadOnlyCollection<SecurityNamespace> securityNamespaces = securityService.GetSecurityNamespaces();
IGroupSecurityService gss = tpc.GetService<IGroupSecurityService>();
Identity SIDS = gss.ReadIdentity(SearchFactor.AccountName, "GroupName", QueryMembership.Expanded);//GourName format: [ProjectName]\\GourpName
IdentityDescriptor id = new IdentityDescriptor("Microsoft.TeamFoundation.Identity", SIDS.Sid);
List<SecurityNamespace> securityList = securityNamespaces.ToList<SecurityNamespace>();
string securityToken;
foreach (SecurityNamespace sn in securityList)
{
if (sn.Description.DisplayName == "Project")
{
securityToken = "$PROJECT:" + ttt.ArtifactUri.AbsoluteUri;
sn.SetPermissions(securityToken, id, 115, 0, true);
}
}
}
}
}
I am trying to get all data into excel using the Get data from web option but I am not sure how to properly configure it. I did get the API key.
EDIT:
Below is the path I use, but that is only the time entries for one user, I need them for ALL users.
https://api.clockify.me/api/v1/workspaces/myWorkspace/user/myUser/time-entries
Any help is appreciated.
EDIT: I didn't read that you wanted to use Power Query in Excel. The Advanced Editor only works with this code in Power BI Desktop.
You'll need to program the request in the Advanced Editor in Power Query.
Here is an example of connecting to the Get Workspace Clients endpoint:
let
baseUrl = "https://api.clockify.me/api/v1/",
apiKey = "your-api-key",
workspaceID = "5dfb421c1b30342708229760",
GetWorkspace = (workspaceID as text) =>
let
options = [Headers = [#"X-Api-Key"= apiKey, #"Content-Type" = "application/Json"],
RelativePath = "workspaces/" & workspaceID & "/clients"],
call = Web.Contents(baseUrl, options),
jsonParsed = Json.Document(call)
in
jsonParsed
in
GetWorkspace
Using this function you just have to change the parameters you need according to the endpoint you want to hit.
The baseUrl will be the same, you'll need to change the RelativePath with the rest of the url and if you need to pass some query parameters, put them after RelativePath in a record, like this:
RelativePath = "workspaces/" & workspaceID & "/clients", Query = [page = "1"]],
I recommend using Postman to make the calls and Fiddler to track how the Url is being constructed. Then compare Postman requests with your power query requests, to check the differences.
Here are some other threads about the subject:
How to access Clockify API through Power Query
How to pull data from Toggl API with Power Query?
Using the TFS 2015 REST API to try to get test runs and results with 404. When fetching projects or teams it works fine.
var uri = $"http://tfsserver:8080/tfs/project/_apis/test/runs/1994/results";
using (WebClient wc = new WebClient())
{
wc.UseDefaultCredentials = true;
wc.Credentials = CredentialCache.DefaultCredentials;
var result = wc.DownloadString(uri);
Console.WriteLine(result);
}
Console.Read();
The following URLs do not work: (NOTE: I removed the server portion because of a limitation of stackoverflow)
.../tfs/project/_apis/test/runs
But these do work:
.../tfs/project/_apis/projects/CodedUi/teams
.../tfs/project/_apis/projects
You are using the wrong url, lack of team project collection name.
http://tfsserver:8080/tfs/Yourcollection/project/_apis/test/runs/1994/results?api-version=1.0
And since there are two versions of API 1.0,3.0, suggest you also add the related API version. More details please refer this tutorial: Get a list of test results
Using the older TFS API, it's possible to access deleted builds using the following code:
IBuildDetailSpec buildDetailSpec = buildServer.CreateBuildDetailSpec(m_teamProject, m_buildDefinition);
buildDetailSpec.BuildNumber = (string.IsNullOrEmpty(m_buildPrefixOverride))? m_buildDefinition + "*" : m_buildPrefixOverride + "*";
buildDetailSpec.MaxBuildsPerDefinition = m_maxBuildPerDefinition;
buildDetailSpec.Status = BuildStatus.All;
buildDetailSpec.QueryDeletedOption = QueryDeletedOption.IncludeDeleted;
buildDetailSpec.QueryOrder = BuildQueryOrder.StartTimeDescending;
buildDetailSpec.InformationTypes = null;
IBuildQueryResult buildQueryResult = buildServer.QueryBuilds(buildDetailSpec);
On the other hand, it seems impossible to query that same thing using the TFS 2015 Update 2 (on-premise) REST API according to the documentation.
This is the query I'm running:
http://tfsserver:8080/tfs/defaultcollection/BuildTools/_apis/build/builds?api-version=2.0&definitions=1227
Did anyone manage to query them? If so, how?
REST API doesn't include query deleted option like .Net API IBuildDetailSpec.QueryDeletedOption.
When get a list of builds for a build definition, REST API below only output the builds not deleted:
http://tfsserver:8080/tfs/defaultcollection/BuildTools/_apis/build/builds?api-version=2.0&definitions=xx
You may consider submit a user voice at website below: https://visualstudio.uservoice.com/forums/121579-visual-studio-2015
I need to get a list of all of the test cases in Rally along with the person who either created them or last modified them.
I thought I could achieve this by getting the changeset but that doesn't appear to have worked - I seem to get a lot of test cases that don't have any changesets at all
String myQuery = "(Method = Manual)";
QueryResult myArtifactReturn = m_rallyService.query(myWorkspace, "TestCase", myQuery, "", true, 0, 100);
long mycount = myArtifactReturn.TotalResultCount;
if (mycount > 0)
{
myArtifact = (TestCase)myArtifactReturn.Results[0];
myArtifact = (TestCase)m_rallyService.read(myArtifact);
Changeset myInitial = (Changeset)m_rallyService.read(myArtifact.Changesets[0]);
}
Is there a way I can do this?
Or is there a way to query Rally to ask for 'all test cases created by User X'?
Thanks
I think you might be mixing up ChangeSets with RevisionHistory. If you're looking to track Revisions on a Rally Artifact, you should look at the RevisionHistory collection. ChangeSets are used by Rally's source code connectors to associate source code commits to various artifacts in Rally.
You might find this answer:
RevisionHistory and Revisions
Instructive for dealing with RevisionHistory in SOAP. The example is for User Stories, but is equally applicable to Test Cases.
Unfortunately, you can't query on RevisionHistory, so you would need to retrieve all the Test Cases that could potentially have matches against your search, and do the filtering for the TestCase creator in your SOAP client. You would need to check the Author attribute for Revision 0:
0 Original revision
2013-Feb-18 09:23:11 AM America/Denver Sam Tester
And verify that it matches your criteria.
Just a heads-up, especially if you're just getting started with building your integration, I'd highly recommend using one of Rally's .NET REST SDK instead of SOAP.
REST is more robust, more performant, and, Webservices API 1.43 was the final API release to have SOAP support, and 1.43 has about 9 months to go (as of 9/2013) before deprecation. Webservices 2.x is REST-only, so using REST will be essential to anyone wanting new Webservices features moving forward.