Citrix DaaS REST APIs

How to add an icon in Citrix DaaS

Use REST APIs to add an icon in your Citrix DaaS (formerly Citrix Virtual Apps and Desktops service) site. Icons are used for creating applications in the 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 add an icon in Citrix DaaS

  • Read the Get started with Citrix Cloud APIs section to ensure that you have the bearer token.
  • Get siteid from How to get site id API.
  • Prepare an icon in ICO format and convert its binary raw data to base64 encoding.
  • Invoke the API described in this document from a client host or from the API exploration tab to add a new icon to the site.

Add an icon in your site using any REST API tool

Learn from the following example to add an icon in your Citrix DaaS site using any REST API tool.

Request

POST https://api.cloud.com/cvad/manage/icons 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

{
    "RawData": "AAABfx4RA...==",
    "IconFormat": "image/png;32x32x24"
}
<!--NeedCopy-->

Response

HTTP/1.1 201 Created
citrix-transactionid: f743c772...
content-Length: 1248
content-Type: application/json; charset=utf-8
date: "Mon, 25 Jan 2021 13:14:57 GMT"

{
    "Id": "c5755e27-2110-4e1c-a5e2-19804bc153fc",
    "IsBuiltIn": false,
    "FormattedData": "TBqrPjEM...===",
    "RawData": "AAABfx4RA...=="
}
<!--NeedCopy-->

Add an icon in your site using PowerShell

Learn from the following example to add an icon in your Citrix DaaS site using any PowerShell code.

function AddIcon {
    param (
        [Parameter(Mandatory=$true)]
        [string] $customerid,
        [Parameter(Mandatory=$true)]
        [string] $siteid,
        [Parameter(Mandatory=$true)]
        [string] $bearerToken,
        [Parameter(Mandatory=$true)]
        [string] $iconModel
    )
    $requestUri = "https://api.cloud.com/cvad/manage/icons"
    $headers = @{
        "Accept" = "application/json";
        "Content-Type"="application/json";
        "Authorization" = "CWSAuth Bearer=$bearerToken";
        "Citrix-CustomerId" = $customerid;
        "Citrix-InstanceId" = $siteid;
    }

    $response = Invoke-RestMethod -Uri $requestUri -Method POST -Headers $headers -Body $iconModel 
    return $response
}

$customerid = "customer1"
$siteid = "61603f15-cdf9-4c7f-99ff-91636601a795"
$bearerToken = "ey1.."
$iconModel = @{
    "RawData" = "AAABfx4RA...==";
    "IconFormat" = "image/png;32x32x24"
}
$response = AddIcon $customerid $siteid $bearerToken (ConvertTo-Json $iconModel)
<!--NeedCopy-->

Add an icon in your site using C# code

Learn from the following example to add an icon in your Citrix DaaS site using C# code.

public static async Task<string> AddIcon(
    string customerid,
    string siteid,
    string bearerToken,
    AddIconRequestModel model)
{
    var requestUri = "https://api.cloud.com/cvad/manage/icons";
    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 jsonBody = JsonConvert.SerializeObject(model, new JsonSerializerSettings
        {
            Converters = new JsonConverter[] { new StringEnumConverter() }
        });

        var response = await client.PostAsync(requestUri, new StringContent(jsonBody, Encoding.UTF8, "application/json"));

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

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

Add an icon in your site using Python

Learn from the following example to add an icon in your Citrix DaaS site using Python.

import requests 

def add_icon(bearerToken, customerid, siteid iconModel):
    request_uri = "https://api.cloud.com/cvad/manage/icons"
    headers = {
                'Authorization': 'CWSAuth Bearer=%s' % bearerToken,
                'Citrix-CustomerId': customerid,
                'Citrix-InstanceId': siteid,
                'Content-Type': 'application/json',
                'Accept': 'application/json'
              }
    payload = json.dumps(iconModel)

    response = requests.post(request_uri, headers = headers, verify = False, data = payload)

    return response.json()
<!--NeedCopy-->
Resources
Citrix DaaS REST APIs OpenAPI Specification
Copy Download
How to add an icon in Citrix DaaS