i have problem with create more dependencies for win32 app in intune.
If i want create or update one dependency i use "updaterelationships" but i need create second dependency i have problem with "relationships". How to add second dependency to intune ?
$Dependency = [ordered]#{
"#odata.type" = "#microsoft.graph.mobileAppDependency"
"dependencyType" = "Detect"
"targetId" = $ID2
#"targetDisplayName"= "Target Display Name value"
#"targetDisplayVersion"= "Target Display Version value"
#"targetPublisher"= "Target Publisher value"
#"targetType"= "parent"
#"dependencyType"= "autoInstall"
#"dependentAppCount"= 1
#"dependsOnAppCount"= 1
}
$Win32AppRelationships = [ordered]#{
"relationships" = #($Dependency)
}
$uri = "https://graph.microsoft.com/beta/deviceAppManagement/mobileApps/$ID/updaterelationships"
Invoke-RestMethod -Uri $uri -Headers $authToken -Method Post -Body ($Win32AppRelationships | ConvertTo-Json) -ContentType "application/json"
}
Response if i use only "relationships" according to https://learn.microsoft.com/en-us/graph/api/intune-apps-mobileappdependency-create?view=graph-rest-beta
Response content:
{"error":{"code":"No method match route template","message":"No OData route exists that match template
~/singleton/navigation/key/navigation with http verb POST for request /AppLifecycle_2208/StatelessAppMetadataFEService/deviceAppManagement/mobileApps
relationships is an array, have you tried appending a second dependency into the array?
"relationships" = #($Dependency1,$Dependency2)
Related
I am trying to list all work item type states for an organisation (visible to the authenticated user) via REST API. It seemed more efficient to list all processes (https://learn.microsoft.com/en-us/rest/api/azure/devops/core/processes/list?view=azure-devops-rest-4.1) and then use the endpoint to list all work item types of those processes together with the states (https://learn.microsoft.com/en-us/rest/api/azure/devops/processes/work-item-types/list?view=azure-devops-rest-4.1&tabs=HTTP). However, I am missing some custom states in the response.
When I list all projects (https://learn.microsoft.com/en-us/rest/api/azure/devops/core/projects/list?view=azure-devops-rest-4.1&tabs=HTTP), then all work item types of those projects (https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/work-item-types/list?view=azure-devops-rest-4.1&tabs=HTTP) and then all states of those types (https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/work-item-type-states/list?view=azure-devops-rest-4.1&tabs=HTTP), there is everything. But that is sooo many requests.
Can someone explain, why is the first approach not working? Every projet should be associated with a process. Or not? Do you know a better way to get all those states as efficiently as possible?
Thanks in advance. :)
As we can see from the official documentation : Work Item Type States - List, it's in project level not the organization level. So, we need to get the states by project scope.
GET https://dev.azure.com/{organization}/{project}/_apis/wit/workitemtypes/{type}/states?api-version=4.1-preview.1
We can write a script to retrieve the projects and work item types in a loop, then get the states of each work item type.
UPDATE:
We can use States - List REST API to return a list of all state definitions in a work item type of the process.
Below PowerShell script for your reference to return the states from a specific process:
Param(
[string]$orgurl = "https://dev.azure.com/{org}",
[string]$processname = "Your-Process-Name",
[string]$user = "",
[string]$token = "PAT"
)
# Base64-encodes the Personal Access Token (PAT) appropriately
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))
#Get Process ID
$processesurl = "$orgurl/_apis/process/processes?api-version=6.0"
$processes = (Invoke-RestMethod -Uri $processesurl -Method Get -Headers #{Authorization=("Basic {0}" -f $base64AuthInfo)}).value | where {$_.name -eq $processname }
$processesid = $processes.id
#List Work item types and witRefName
$witsurl = "$orgurl/_apis/work/processes/$processesid/workitemtypes?api-version=6.0"
$witRefNames = (Invoke-RestMethod -Uri $witsurl -Method Get -Headers #{Authorization=("Basic {0}" -f $base64AuthInfo)}).value.referenceName #| where {$_.name -eq $processname }
#List WIT states
foreach ($witRefName in $witRefNames){
$statesurl = "$orgurl/_apis/work/processes/$processesid/workItemTypes/$witRefName/states?api-version=6.0"
$states = (Invoke-RestMethod -Uri $statesurl -Method Get -Headers #{Authorization=("Basic {0}" -f $base64AuthInfo)}).value.name
Write-Host "==================================================================================="
Write-Host "$witRefName - States:" $states
Write-Host "==================================================================================="
echo `n
}
If you want to retrieve all states from all processes, then you can get the processes and loop them in the script.
I was successfully able to fetch the workitems under a project using the below http request.
http://dev.azure.com/{organization}/{project}/_apis/wit/reporting/workitemrevisions?includeLatestOnly=true&api-version=5.0-preview.2
Similarly, i need to fetch the team workitems, this is the request i had used.
http://dev.azure.com/{organization}/{project}/{team}/_apis/wit/reporting/workitemrevisions?includeLatestOnly=true&api-version=5.0-preview.2
But, i am not getting the workitems.
Can anyone help me with the syntax.
You can get the work items on a team's Taskboard with:
GET https://dev.azure.com/{organization}/{project}/{team}/_apis/work/taskboardworkitems/{iterationId}?api-version=6.0-preview.1
and on a team Iteration with:
GET https://dev.azure.com/{organization}/{project}/{team}/_apis/work/teamsettings/iterations/{iterationId}/workitems?api-version=6.0-preview.1
You could also do a WIQL query:
$AreaPath = "{Project}\{PathYou'reInterestedIn}"
# Example WIQL gets all User Stories and Bugs that are not removed
$wiql = #"
SELECT
[System.Id]
FROM workitems
WHERE
[System.TeamProject] = '$($AreaPath.Split("\")[0])'
AND [System.AreaPath] UNDER '$($AreaPath.Replace("\", "\\"))'
AND [System.State] <> 'Removed'
AND [System.WorkItemType] IN ('User Story', 'Bug')
ORDER BY [System.ChangedDate] DESC
"#
$uri = "https://dev.azure.com/{org}/_apis/wit/wiql?api-version=6.1-preview.2"
# add your access token to the headers
$headers = #{ Authorization = "Basic " + + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$YourAccessTokenValue"))
# I wrote the WIQL to be readable - this makes it suitable for a JSON request
$query = #{ query = ($wiql.split([System.Environment]::NewLine) | `
ForEach-Object { "$($_.Trim())" }) -join " " } | `
ConvertTo-Json
$workItemList = (Invoke-RestMethod -Uri $uri -Headers $headers -Method Post -Body $query).workItems
If I have just the package name, is it possible to get the package ID using a single API call. Looks like Package ID is required for any further API calls - to get versions of a package etc.,
Or is the only way to get all the packages from the feed, match with the name and then get the ID from that?
Reference API: https://learn.microsoft.com/en-us/rest/api/azure/devops/artifacts/artifact%20%20details/get%20package?view=azure-devops-rest-6.0
You can specify a packageNameQuery query parameter in the Get Packages rest api to retrieve the package's information with a given name.
GET https://feeds.dev.azure.com/{organization}/{project}/_apis/packaging/Feeds/{feedId}/packages?protocolType={protocolType}&packageNameQuery={packageNameQuery}&normalizedPackageName={normalizedPackageName}&includeUrls={includeUrls}&includeAllVersions={includeAllVersions}&isListed={isListed}&getTopPackageVersions={getTopPackageVersions}&isRelease={isRelease}&includeDescription={includeDescription}&$top={$top}&$skip={$skip}&includeDeleted={includeDeleted}&isCached={isCached}&directUpstreamId={directUpstreamId}&api-version=6.0-preview.1
For Organization scoped feeds:
$url= "https://feeds.dev.azure.com/{organization}/_apis/packaging/Feeds/{feedid or feedName}/packages?packageNameQuery={package Name}&api-version=6.0-preview.1"
For Project scoped feeds:
$url= "https://feeds.dev.azure.com/{organization}/{project}/_apis/packaging/Feeds/{feedid or feedName}/packages?packageNameQuery={package Name}&api-version=6.0-preview.1"
See below example:
#Organization scoped feed
$url= "https://feeds.dev.azure.com/{organization}/_apis/packaging/Feeds/{feedid or feedName}/packages?packageNameQuery={package Name}&api-version=6.0-preview.1"
$PAT="Personal Access Token"
$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($PAT)"))
$ArtInfo = Invoke-RestMethod -Uri $url -Headers #{Authorization = ("Basic {0}" -f $base64AuthInfo)} -Method get
I am trying to create Channel of Team with email address (for example, General - Test Team 72 <527ce911.YYY.XX#emea.teams.ms>). I can create Channel but without email address.
I have tried following using Graph API (Powershell):
1. Graph API v1.0 and beta
2. Create Team (public, private with email) with default (General) Channel
3. Create additional Channels for existing Team
4. Create O365 group and from group create Team
5. Add members and owners to Team
6. Update/change settings of Team and channel
7. Create Channel's folder in the document library of SharePoint site linked to Team
function create-team($TeamName, $Visibility, $UserId){
$ApiUrl = "https://graph.microsoft.com/beta/teams"
$Method = "Post"
$MailNickname = $TeamName -replace '\s',''
$Body = #{
"template#odata.bind" = "https://graph.microsoft.com/beta/teamsTemplates('standard')";
"displayName" = "$TeamName";
"description" = "$TeamName";
"owners#odata.bind" = #("https://graph.microsoft.com/beta/users('$UserId')");
"Visibility" = "$Visibility";
"mailNickname" = "$MailNickname"
}
$BodyJSON = ConvertTo-Json $Body
$ContentType = "application/json"
#$AccessToken is not shown here
return Invoke-RestMethod -Headers #{Authorization = "Bearer $AccessToken"} -Uri $ApiUrl -Method $Method -Body $BodyJSON -ContentType $ContentType
}
function create-channel($TeamId, $DisplayName, $Description){
$ApiUrl = "https://graph.microsoft.com/beta/teams/$TeamId/channels"
$Method = "Post"
$Body = #{
"displayName" = "$DisplayName";
"description" = "$Description";
#"channelState" = "Active";
"groupId" = "$TeamId"
}
$BodyJSON = ConvertTo-Json $Body
$ContentType = "application/json"
#$AccessToken is not shown here
return Invoke-RestMethod -Headers #{Authorization = "Bearer $AccessToken"} -Uri $ApiUrl -Method $Method -Body $BodyJSON -ContentType $ContentType
}
I can not create a Channel using Graph API (Powershell) of Microsoft Team with email address. I can create Team with default Channel (General) or/and add additional Channels but they all do not have email addresses. When I choose " ... -> Get email Address" of the Channel in the web page I get following message infinitely (couple days):
We're still setting up your team.
Please try again later.
In the document library (Documents) of the SharePoint linked site I do not see a folder General if we talking about General Channel. But after I click to attach a document to Channel in the Conversations tab I get following message:
We're setting up your files.
Check back in a few minutes.
and after several seconds arrise email address in the Channel and folder General in the SharePoint site.
Is it possible to create Channel using GraphAPI with email?
Im trying to queue a new build using the TFS 2015.3 REST API, i have followed many articles but cannot get it to work.
I am executing this in PowerShell, a standard queue new build call works when passing only the Definition ID, but passing anything else in addition to the id doesn't seem to work.
my code:
$buildDef = Invoke-RestMethod -Method Get -UseDefaultCredentials -Uri "$($tfsRoot)/_apis/build/definitions?api-version=2.0&name=$buildDefintionName"
$detailedResults = Invoke-RestMethod -Uri $buildDef.Value[0].Url -Method Get -ContentType "application/json" -UseDefaultCredentials
if ($buildDef.Value[0].Id)
{
$agentDemandString = "Agent.Name -equals $agent"
$demands = $detailedResults.Demands
$json = "definition: { id:$($buildDef.Value[0].Id) }, demands: $demands"
$bodyjson = $json | ConvertTo-Json
Write-Host "Queuing build $buildDefintionName on agent $agent with parameters $json"
$build = Invoke-RestMethod -Method Post -UseDefaultCredentials -ContentType application/json -Uri "$($tfsRoot)/_apis/build/builds?api-version=2.0" -Body $bodyjson
}
I have tried many different variations of passing the demands, but it looks like it is not even getting to that point as its complaining about the "build" parameter.
Invoke-RestMethod : {"$id":"1","innerException":null,"message":"Value cannot be null.\r\nParameter name: build","typeName":"System.ArgumentNullException, mscorlib, Version=4.0.0.0, Culture=neutral
If im right the build parameter contains the build steps to execute. Which makes me think that the queued build is dropping all existing configuration and tries to rely only on what has been passed in the JsonBody, this is ofcourse not what i want.
What and how should i pass in order to queue a new build but with updated/additional demands.
I finaly got it working with some help. The Demands property is accepted.
Looks like it was not working because of the powerShell code with Json conversion. If i use below and dont convert it to Json, it works !
Function queuebuild{
$uri="$($tfsRoot)/_apis/build/builds?api-version=2.0"
$body='{
"definition": {
"id": 1061
},
"sourceBranch": "$/Project/Branch",
"demands":["Demand1", "Agent.Name -equals Computer2-E-A2"]
}';
$result=Invoke-RestMethod -Uri $uri -Method Post -ContentType "application/json" -UseDefaultCredentials -Body $body
}
Try to set the depth:
$bodyjson = $json | ConvertTo-Json -Depth 3
$json = "definition: { id:$($buildDef.Value[0].Id) }, demands: $demands" is not going to be valid JSON -- it wouldn't be wrapped in curly braces, for example.
I recommend creating an associative array that will properly convert to valid JSON. The example JSON provided in the documentation is:
{
"definition": {
"id": 25
},
"sourceBranch": "refs/heads/master",
"parameters": "{\"system.debug\":\"true\",\"BuildConfiguration\":\"debug\",\"BuildPlatform\":\"x64\"}"
}
So this would generate an appropriate JSON object:
$body = #{
definition = #{ id=25 }
sourceBranch = 'refs/heads/master'
parameters = '{\"system.debug\":\"true\",\"BuildConfiguration\":\"debug\",\"BuildPlatform\":\"x64\"}'
}
$body | convertto-json
Or if you wanted to be extra fancy and eliminate the inner JSON-as-a-string bit:
$body = #{
definition = #{ id=25 }
sourceBranch = 'refs/heads/master'
parameters = (#{'system.debug' = $true; BuildConfiguration='debug'; BuildPlatform='x64'}) | convertto-json -Compress
}
$body | convertto-json
Based on my test, we cannot Set Demands directly with the Queue build REST Api.
The build will still use the agent which was set in definition even though we specified other agents with the "Demands" set when queue the build. You can check this with the REST API, below screenshot for your reference.
And with the REST API to get a build eg:
GET http://SERVER:8080/tfs/CollectionLC/6debd6ea-fa97-4ea2-b0c0-3cbbc4afa802/_apis/build/Builds/1071/
You can see that, the "Demands" is not included in the response. It only appears in build definition response.
Actually, the "Demands" is set in build definition,it's against the build definition only. When queue a build with REST API, it just trigger the build definition. So, if you want to trigger build with the specific agent using REST API, you need to update the definition (set demands )first, then trigger the build definition.
To update the definition use the REST API : See Update a build definition
PUT https://{instance}/DefaultCollection/{project}/_apis/build/definitions/{definitionId}?api-version={version}
So, you can write the script to update build definition fist, then trigger the build with build definition ID.