cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MarkBarrett67
Frequent Visitor

Sending WIQL query in Send HTTP Request to Azure DevOps error

I am attempting to run a WIQL query by sending the query in the Send HTTP Request to Azure DevOps as outlined in this issue https://powerusers.microsoft.com/t5/Power-Automate-Community-Blog/Create-Update-Parameterized-Querie...

However, when I attempt to send the query with a POST, I get the result "You must pass a query object in the body of the request." I do have a query in the body of the request. Does a WIQL query have to exist in Azure DevOps in order to call it? According to the screenshots in the link above, the relative uri is "{project}/_apis/wit/queries/My Queries/{Name of Query in JSON Body of request}?api-version=5.0". My relative uri is "{project}/_apis/wit/wiql?api-version=5.0". I have tried switching to the "queries/My Queries" uri as in the screenshot in the linked issue but I get the error "the query does not exist or you do not have permissions for it". The query doesn't exist, I am attempting to run it but from the screenshots in the link, it appears they are pointing to the My Queries of Azure and I would assume his query must be there or would get the same resulting error as I did?  I have switched between api versions 5.0 & 5.1 and get the same error. Switching to 6.0 gets me an Unauthorized error. I have also switched between a POST and GET with the same error and when I try using PATCH as in the screenshots in the link, I get 

TF400813: The user '27313870-5aa3-6c6c-a627-e8384e26de1a' is not authorized to access this resource.

Here is screenshot of my Send HTTP request to Azure DevOps:

MarkBarrett67_0-1637272403974.png

 

Do I need to pass authentication like a PAT token in the headers? What am I missing here to get this HTTP call with a WIQL query to work? Thanks so much for any assistance. It is greatly appreciated.

 

1 REPLY 1
Red2
Microsoft
Microsoft

Hi Mark,

 

Per Wiql - Query By Wiql - REST API (Azure DevOps Work Item Tracking) | Microsoft Docs

 

You should be able to send a generated WIQL call using:

POST https://dev.azure.com/fabrikam/_apis/wit/wiql?api-version=5.0

Body:

{
  "query": "Select [System.Id], [System.Title], [System.State] From WorkItems Where [System.WorkItemType] = 'Task' AND [State] <> 'Closed' AND [State] <> 'Removed' order by [Microsoft.VSTS.Common.Priority] asc, [System.CreatedDate] desc"
}

 

This way you could create and store the queries in Power Automate since it looks like you're looking to dynamically update them anyway.

 

-Red

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (5,112)