Citrix Virtual Apps and Desktops REST APIs

How to get status of an asynchronous job

Use REST APIs to get details of an asynchronous job in your Citrix Virtual Apps and Desktops site.

Follow the prerequisites and examples to get started with this API.

You can make API requests using the PowerShell code, C# code, Python, or any tool that supports invoking the REST API.

Prerequisites to get status of an asynchronous job

Get details of a single job using any REST API tool

Learn from the following example to get the details of a single job in your Citrix Virtual Apps and Desktops site using any REST API tool.

Request

GET https://[DdcServerAddress]/cvad/manage/Jobs/{id} HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=utf-8
Authorization: CWSAuth bearer=<token-from-prerequisites>
Citrix-CustomerId: loy6oujtu6a4
Citrix-InstanceId: 22ded57c-0306-47e4-b6e8-fed6252759e1
<!--NeedCopy-->

Response

HTTP/1.1 200 OK
citrix-transactionid: 284de2fe...
content-Length: 558
content-Type: application/json; charset=utf-8
date: "Mon, 12 Oct 2020 07:21:54 GMT"

{
    "Id": "4561cc8d...",
    "Type": "AddMachineCatalogMachine",
    "OverallProgressPercent": 100,
    "IsCancellable": false,
    "Parameters": [
        {
            "Name": "NameOrId",
            "Value": "CVAD_APIs_Physical_MC"
        },
        {
            "Name": "request",
            "Value": "[{\"PvsAddress\":null,\"PvsDomain\":null,\"PvsCollectionIds\":null,\"MachineAccountCreationRules\":null,\"AddAvailableMachineAccount\":null,\"MachineName\":\"ORCHPERFS2\\\\Ops2Machine-0002\",\"AssignedClientName\":null,\"AssignedIPAddress\":null,\"AssignedUsers\":null,\"HostedMachineId\":null,\"HypervisorConnection\":null,\"InMaintenanceMode\":null},{\"PvsAddress\":null,\"PvsDomain\":null,\"PvsCollectionIds\":null,\"MachineAccountCreationRules\":null,\"AddAvailableMachineAccount\":null,\"MachineName\":\"ORCHPERFS2\\\\Ops2Machine-0003\",\"AssignedClientName\":null,\"AssignedIPAddress\":null,\"AssignedUsers\":null,\"HostedMachineId\":null,\"HypervisorConnection\":null,\"InMaintenanceMode\":null}]"
        }
    ],
    "SubJobs": [],
    "Status": "Complete",
    "ResultLocation": "/MachineCatalogs/CVAD_APIs_Physical_MC",
    "ErrorString": null,
    "ErrorCode": null,
    "ErrorParameters": [],
    "CreationTime": "2020-10-12T07:21:37.815+00:00",
    "StartTime": "2020-10-12T07:21:37.824+00:00",
    "EndTime": "2020-10-12T07:21:46.382+00:00"
}
<!--NeedCopy-->

Get details of a single job using PowerShell

Learn from the following example to get the details of a single job in your Citrix Virtual Apps and Desktops site using any PowerShell code.

function GetJob {
    param (
        [Parameter(Mandatory=$true)]
        [string] $customerid,
        [Parameter(Mandatory=$true)]
        [string] $siteid,
        [Parameter(Mandatory=$true)]
        [string] $id,
        [Parameter(Mandatory=$true)]
        [string] $bearerToken
    )
    $requestUri = [string]::Format("https://[DdcServerAddress]/cvad/manage/Jobs/{0}", $id)
    $headers = @{
        "Accept" = "application/json";
        "Authorization" = "CWSAuth Bearer=$bearerToken";
        "Citrix-CustomerId" = $customerid;
        "Citrix-InstanceId" = $siteid;
    }

    $response = Invoke-RestMethod -Uri $requestUri -Method GET -Headers $headers 
    return $response
}

$customerId = "customer1"
$siteId = "61603f15-cdf9-4c7f-99ff-91636601a795"
$id = "56f1cbf3-1cc6-40cd-9c82-c95633ba88bb"
$bearerToken = "ey1.."
$response = GetJob $customerid $siteid $id $bearerToken 
<!--NeedCopy-->

Get details of a single job using C# code

Learn from the following example to get the details of a single job in your Citrix Virtual Apps and Desktops site using any C# code.

public static async Task<string> GetJob(
    string customerid,
    string bearerToken,
    string siteid,
    string id)
{
    var requestUri = string.Format("https://[DdcServerAddress]/cvad/manage/Jobs/{0}", id);
    using (var client = new HttpClient())
    {
        client.DefaultRequestHeaders.Accept.ParseAdd("application/json");
        client.DefaultRequestHeaders.Add("Citrix-CustomerId", customerid);
        client.DefaultRequestHeaders.Add("Citrix-InstanceId", siteid);
        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("CWSAuth Bearer=" + bearerToken);

        var response = await client.GetAsync(requestUri);

        if (response != null)
        {
            var content = await response.Content.ReadAsStringAsync();
            return content;
        }

        return null;
    }
}
<!--NeedCopy-->

Get details of a single job using Python

Learn from the following example to get the details of a single job in your Citrix Virtual Apps and Desktops site using Python.

import requests 

def get_job(bearerToken, customerid, siteid, id):
    request_uri = "https://[DdcServerAddress]/cvad/manage/Jobs/{0}".format(id)
    headers = {
                'Authorization': 'CWSAuth Bearer=%s' % bearerToken,
                'Citrix-CustomerId': customerid,
                'Citrix-InstanceId': siteid,
                'Content-Type': 'application/json',
                'Accept': 'application/json'
              }

    response = requests.get(request_uri, headers = headers)

    return response.json()
<!--NeedCopy-->
Resources
Citrix Virtual Apps and Desktops REST APIs OpenAPI Specification
Copy Download
How to get status of an asynchronous job