azure-devops

Azure DevOps REST Agents request missing last Completed Property


I am trying to get the last completed property from the REST Agents List api.

from:

GET https://dev.azure.com/{organization}/_apis/distributedtask/pools/{poolId}/agents?agentName={agentName}&includeCapabilities={includeCapabilities}&includeAssignedRequest={includeAssignedRequest}&includeLastCompletedRequest={includeLastCompletedRequest}&propertyFilters={propertyFilters}&demands={demands}&api-version=5.1

I create my request:

http://136.202.16.216:8070/_apis/distributedtask/pools/4/agents?agentName=MyAgent&includeCapabilities=true&includeAssignedRequest=true&includeLastCompletedRequest=true

as result I get:

assignedRequest: {requestId: 1033, queueTime: "2019-09-11T12:27:22.83Z", assignTime: "2019-09-11T12:27:22.8466667Z", receiveTime: "2019-09-11T12:27:54.9251264Z", lockedUntil: "2019-09-11T12:37:55.1333333Z", …}
authorization: {clientId: "caab7294-98dc-41ed-88cd-68e11a08b835", publicKey: {…}}
createdOn: "2019-07-02T09:53:38.727Z"
enabled: true
id: 10
maxParallelism: 1
name: "MyAgent"
osDescription: "Microsoft Windows 10.0.17134 "
provisioningState: "Provisioned"
status: "online"
systemCapabilities: {Agent.Name: "MyAgent", Agent.Version: "2.144.2", Agent.ComputerName: "MyAgent", Agent.HomeDirectory: "D:\AzureDevOpsData\AgentD", Agent.OS: "Windows_NT", …}
version: "2.144.2"
_links: {self: {…}, web: {…}}

But the includeLastCompletedRequest property is missing. It will also missing when the agent have no assignedRequest, I allready test this case.

Have anybody expirence with this request?


Solution

  • I tested and found the includeLastCompletedRequest would be missing from the response result, if the agent never ran a job before. When i tested on an agent which had ran a job, this property correctly showed in the result.

    The server seems to omit the property with null value from the response. You can check if the agent your queried ever ran a job before.