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
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power automate tips 768x460 v2.png

Restore a Deleted Flow

Did you know that you could restore a deleted flow? Check out this helpful article.

Top Kudoed Authors
Users online (3,191)