VSTS API - Get test category information for test run - azure-devops

I have been looking to get hold of test results programatically, for the tests that are run during builds and releases. I am doing it via the VSTS API here.
https://www.visualstudio.com/en-us/docs/integrate/api/test/results
The test category information, declared via [TestCategory] attribute, does not appear in this results returned by this API.
I am wondering if there is a way to get hold of test results along with category information?
The test category information is available within the downloaded test results file using the UI from within the test run details.
Is there an API endpoint that return path to the test results file (the one that can be downloaded via the UI)?
Any pointers will be greatly appreciated.
Thanks

To get TestCategory from test file (such as .trx), you use use the REST API to download a test run attachment instead of using the REST API to get test result(s) from a test run.
You can get the test run attachment id firstly, and then download the attachment:
To get the attachment id, use the REST API:
GET https://account.visualstudio.com/DefaultCollection/project/_apis/test/runs/runId/attachments?api-version=3.0-preview
And you can get the attachment id by the id parameter.
To download the attachment, use the REST API:
GET https://account.visualstudio.com/DefaultCollection/project/_apis/test/runs/runId/attachments/attachmentId?api-version=3.0-preview
To get the TestCategory, you can find in the response part:
<TestCategory>
<TestCategoryItem TestCategory="name" />
</TestCategory>

Related

How to get an asset all details in AEM with API request?

I am using AEM API in my automation. We published a file from workfront to AEM. That file have multiple information:
1. Basic
2. Test1
3. test2
4. etc
When I hit the api:
/api/assets/..../abc.pdf.json
I am getting very less information under the properties and metadata section. (In short, it does not have Test1, Test2 and other tab information)
Is there any way to fetch all these from aem API's? It will reduce my overhead to validate these details from UI Automation.
First of look checkout the metadata nodes of file for the desired data to be present. I would rather prefer writing a custom servlet in AEM which takes in path parameter as an asset path and gives back the response back in desired format.
I figured it out.
The following API returns all the JCR content in API response:
<baseURL>/content/dam/path to that file.-1.json

AzureDevops API builds list API returns empty json results

I am unable to get a list of builds when using the devops api (I am requesting it without any additional filters)
https://dev.azure.com/{organization}/{project}/_apis/build/builds?api-version=5.1
It returns the following
{ "value": [ ], "count": 0 }
It seems that the API is working other wise as if the following URL is working and returning a full details about the build
https://dev.azure.com/{organization}/{project}/_apis/build/builds/{buildId}?api-version=5.1
I am using token authentication and all the other tests seem to work as I would expect. All the {variables} are replaced with my queries, but have left them in as that is somewhat sensitiv(e.
Am I missing something? Is the API broken?
AzureDevops API builds list API returns empty json results
As test, the rest api Builds - List works fine:
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds?api-version=5.1
I test it with postman by using the PAT (only have the build read scope of access):
So, the REST API is fine.
Besides, since you could also get the result with a specify a build Id, please confirm if there are any errors in your url and if there are too many pipelines in your project, which has not returned the correct value in time. You could test it with a new test project.
Besides, what Eric said is also a possibility, please make sure the token authentication have permission to read all pipeline, you could create a PAT with build read scope of access.
Hope this helps.

How to get version history of a file in folder in sharepoint using SharePoint REST API using c#?

I have a SharePoint library with a file in it. I need to get previous versions of the file who created it and when. What is the rest endpoint to fetch those details. I am new to SharePoint. Please help
You could use this rest endpoint to get previous versions of the file by the file id:
https://<server>/sites/<site>/_api/web/lists/getByTitle('Documents')/items(1)/versions
You could add filters at the end to get the information you need:
https://<server>/sites/<site>/_api/web/lists/getByTitle('Documents')/items(1)/versions?$select=VersionLabel,Created_x005f_x0020_x005f_By,Created
in order to get additional information from REST API request You need to use the $expand property. If You need information like who made the update please add '?$expand=CreatedBy' at the end of the request.. so for Your example it will be something like:
https:///sites//_api/web/GetFolderByServerRelativeUrl('Shared%20Documents/general')/files('SampleDocFile.docx')/versions?$expand=CreatedBy
that way You will have the user who modified the file in
content>properties>Title
other interesting data is:
updated>
content>properties>CheckInComment>
content>properties>VersionLabel>

Get test suite id using Azure DevOps API

I am trying the below API, to get the suite ID using test case ID,
http://tfsb.xxx.com/xxx/xxxSoftware/_api/_testManagement/suites?testCaseId=185295&api-version=5.0
But I always get the below response:
404 - File or directory not found.
Can any you please tell me how to get the suite ID using testcase ID for Azure DevOps?
This is not the correct API, according to the docs there is a special API for this - Get Suites By Test Case Id:
GET https://dev.azure.com/{organization}/_apis/test/suites?testCaseId={testCaseId}&api-version=5.0
Been struggling with this all morning. Finally figured out how to get it to work. You should not put the project / team name in the URL. For example, most API calls look like:
https://dev.azure.com/{organization}/{project}/_apis/
However, the correct URL for this api call should look like:
https://dev.azure.com/{organization}/_apis/
In other words just put the base organization but do not put the project/team.
Same if you are using a dedicated organization url, instead of:
https://mycompany.visualstudio.com/Bigproject/_apis/
you must do
https://mycompany.visualstudio.com/_apis/

how to get all the Task in a Workitem in Json form by postman for TFS API

i am currently using TFS API who's link is
https://www.visualstudio.com/en-us/docs/integrate/api/wit/work-items#byids
currently in my project i want to accees the following workitem 61092 all the task
http://apactfs.cbre.com:8080/tfs/CBRE.APAC.Applications/MRI_SCRUM_GIT/_workitems?_a=edit&id=61092
for that i am using this link in postman GET
http://apactfs.cbre.com:8080/tfs/cbre.apac.applications/_apis/wit/workitems/61092?$expand=all&api-version=1.0
i am getting all the task related to it but not getting all the field such as number of hours in the task,user of the task which i wanted.
and in Postman i am hitting the id by this Link By GET
http://apactfs.cbre.com:8080/tfs/cbre.apac.applications/MRI_SCRUM_GIT/_workitems?_a=edit&id=61092&api-version=1.0
According to your screenshot, 61092 is a Product Backlog Item. The Rest API URL you use can only get the detailed information of the work item 61092 itself, it cannot get the detailed information about the work items that linked to 61092.
You have to use One-hop Query to get all the tasks related to it and then get the detailed data for each task returned. Refer to this link for details: Get Work Items.
$expand=all has already expand all fields, but it doesn't show the empty fields in response. If you type a value for the field you want to get, you will see it as expect in response.