azure-devops-rest-api

How to call the Azure DevOps Identities Rest service using az devops invoke


How do I call this service using az devops invoke?

https://learn.microsoft.com/en-us/rest/api/azure/devops/ims/?view=azure-devops-rest-7.1

Specifically with the following query parameters:

https://vssps.dev.azure.com/{orgName}/_apis/identities?searchFilter=General&filterValue={identity}&queryMembership=None&api-version=7.1

When I access this in a browser it returns data. I've been trying to do the same with the cli:

az devops invoke `
--query-parameters searchFilter=General filterValue=$($identity_name) queryMembership=None `
--org "https://vssps.dev.azure.com/$orgName" `
--area IMS `
--resource Identity `
--api-version 7.1

I get the following warning and error: The Azure DevOps Extension for the Azure CLI does not support Azure DevOps Server. The requested resource does not support http method 'GET'.


Solution

  • I can reproduce the same error when using the same script as yours.

    enter image description here

    There are two mistakes in your script:

    1. The correct value of '--org' should be the URL of Azure DevOps organization "https://dev.azure.com/$orgName".

    2. The correct value of '--resource' should be 'Identities'.

    So, you need to update your script like as below.

    $pat="xxxx"
    $orgName="xxxx"
    $identity_name = "xxxx"
    
    Write-Output $pat | az devops login --org https://dev.azure.com/$orgName
    
    az devops invoke `
    --org https://dev.azure.com/$orgName `
    --query-parameters searchFilter=General filterValue=$identity_name queryMembership=None `
    --area IMS `
    --resource Identities `
    --api-version 7.1
    

    enter image description here