You can only execute a Rest API Task through an agentless job?

Copper Contributor

I was looking for examples of using the Azure DevOps Rest API from within a pipeline yml file (without using postman).  Get info about another build, get or update Board issues info, whatever.

 

I found Invoke HTTP REST API task - Azure Pipelines | Microsoft Learn, which says "This task can be used in only an agentless job".

 

I found this... Azure Pipelines- Agentless/Server jobs (bartwullems.blogspot.com)

The header says...Azure Pipelines- Agentless/Server jobs".  "Tasks in a server job are orchestrated by and executed on the server (Azure Pipelines or TFS). A server job does not require an agent or any target computers."

 

Is this saying that only "Azure DevOps Server" (downloaded and installed on your own hardware), can run agentless jobs, and thus if you are using "Azure DevOps Service (the cloud), you cannot use the Rest API task in a pipeline?

 

3 Replies

I said at the beginning "I was looking for examples of using the Azure DevOps Rest API from within a pipeline yml file". Pretty much indicates that I am new to this.

After more research, it appears that the way to use the Rest API in a pipeline yml file is to use PowerShell Invoke-RestMethod \ "$URL = ", and the 'InvokeRESTAPI@1' is only used in Agentless jobs.

Of 40 + people who looked at this posting, no one knew that?

Hey can you please let me know how you used InvokeRESTAPI@1 task ?

My requirement is to get the triggerInfo.scheduleName information via API call and pass it to next stages in the pipeline.
I never used it. When editing a pipeline, it is a task that you can add (for Agentless pipelines).
https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/invoke-rest-api-v1?view=azu...

If you are using a pipeline that uses a build agent, there are many samples out there, here is one, https://www.opentechguides.com/how-to/article/azure/201/devops-rest-powershell.html