Citrix DaaS REST APIs

How to make an asynchronous API call

Use REST APIs to make an asynchronous API call in your Citrix DaaS (formerly Citrix Virtual Apps and Desktops service) 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 make an asynchronous API call

  • Read the Get started with Citrix Cloud APIs section to ensure that you have the bearer token.
  • Make sure parameter async is available in the Query Parameters.
  • Prepare the necessary parameters for the API you want to use.
  • Invoke the API described in this document from a client host or from the API exploration tab to make an asynchronous API call.
  • To get the job status and details, invoke the API described in How to get status of an async job with the response Location header value.

Make an asynchronous API call using any REST API tool

Learn from the following example to make an asynchronous API cal in your Citrix DaaS site using any REST API tool.

Request

GET https://api.cloud.com/cvad/manage/MachineCatalogs?async=true 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 202 Accepted
citrix-transactionid: 76c93e78...
content-Length: 0
content-Type: application/json; charset=utf-8
date: "Wed, 21 Oct 2020 07:47:14 GMT"
Location: https://api.cloud.com/cvad/manage/Jobs/81c05d9f...
<!--NeedCopy-->

Make an asynchronous API call using PowerShell

Learn from the following example to make an asynchronous API call in your Citrix DaaS site using any PowerShell code.

function GetMachineCatalogs {
    param (
        [Parameter(Mandatory=$true)]
        [string] $customerid,
        [Parameter(Mandatory=$true)]
        [string] $siteid,
        [Parameter(Mandatory=$true)]
        [string] $bearerToken
    )
    $requestUri = "https://api.cloud.com/cvad/manage/MachineCatalogs?async=true"
    $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 = "n2ypkklgy6cv"
$siteid = "12f7438-bf8e-42ba-b1b3-2eb75d098f57"
$bearerToken = "eyJ..."
$response = GetMachineCatalogs $customerid $siteid $bearerToken  
<!--NeedCopy-->

Make an asynchronous API call using C# code

Learn from the following example to make an asynchronous API call in your Citrix DaaS site using any C# code.

public static async Task<string> GetMachineCatalogs(
    string customerid,
    string bearerToken,
    string siteid)
{
    var requestUri = "https://api.cloud.com/cvad/manage/MachineCatalogs?async=true";
    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-->

Make an asynchronous API call using Python

Learn from the following example to make an asynchronous API call in your Citrix DaaS site using Python.

import requests 

def get_machine_catalogs(bearerToken, customerid, siteid):
    request_uri = "https://api.cloud.com/cvad/manage/MachineCatalogs?async=true"
    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 DaaS REST APIs OpenAPI Specification
Copy Download
How to make an asynchronous API call