How to get a site ID in Citrix DaaS
Use the REST APIs to get the structure of a load-balanced site in your session recording service. You can also get the session recording servers’ detail inside every site. Site id and server id are mandatory headers in many APIs which required to be fetched at first. Follow the prerequisites and examples to get started with this API.
You can make API requests using PowerShell, C# code, Python, or any tool that supports invoking the REST API.
Prerequisites
- Read Get started with Citrix Cloud APIs to ensure that you have obtained the
customerId
andbearer token
. - Invoke the API described in this document from a client host or from the API exploration tab to get the site ID and more details.
Get a site ID using any REST API tool
This is an example showing how to get site ID and more details using any REST API tool.
Request
GET https://sessionrecording.apps.cloud.com/api/site HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=utf-8
Authorization: CWSAuth bearer=<token-from-prerequisites>
Citrix-CustomerId: loy6oujtu6a4
<!--NeedCopy-->
Response
HTTP/1.1 200 OK
citrix-transactionid: c1d5b5d4...
content-Length: 435
content-Type: application/json; charset=utf-8
date: "Wed, 16 Sep 2020 04:19:10 GMT"
[
{
"siteName": "SITE1",
"siteDescription": "",
"servers": [
{
"serverName": "SERVER1",
"serverId": "a5894bae-5bc0-9f3a-562b-3e5ae3c5f08b",
"serverDescription": "",
"serverStatusType": 3,
"serverStatusTypeA": 0,
"serverStatusTypeB": 0,
"serverClientVersion": "7.38.25618.35833",
"serverSoftwareVersion": "22.12.0.0"
}
],
"siteId": "4e324e87-1716-4414-982c-071bca8d69a0",
"siteHashCode": null
},
...
]
<!--NeedCopy-->
Get a site ID using PowerShell
This is an example showing how to get site ID and more details using any PowerShell code.
function GetSites {
param (
[Parameter(Mandatory=$true)]
[string] $bearerToken,
[Parameter(Mandatory=$true)]
[string] $customerId
)
$requestUri = "https://sessionrecording.apps.cloud.com/api/site"
$headers = @{
"Accept" = "application/json";
"Authorization" = "CWSAuth Bearer=$bearerToken";
"Citrix-CustomerId" = $customerid;
}
$response = Invoke-RestMethod -Uri $requestUri -Method GET -Headers $headers
return $response
}
$bearerToken = "ey1.."
$customerId = "customer1"
$response = GetMe $bearerToken $customerId
<!--NeedCopy-->
Get a site ID using C# code
This is an example showing how to get site ID and more details using any C# code.
public static async Task<string> GetSites(
string customerid,
string bearerToken)
{
var requestUri = "https://sessionrecording.apps.cloud.com/api/site";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.ParseAdd("application/json");
client.DefaultRequestHeaders.Add("Citrix-CustomerId", customerId);
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 a site ID using Python
This is an example showing how to get site ID and more details using Python.
import requests
def get_sites(bearerToken):
request_uri = "https://sessionrecording.apps.cloud.com/api/site"
headers = {
'Authorization': 'CWSAuth Bearer=%s' % bearerToken,
'Citrix-CustomerId': customerid,
'Content-Type': 'application/json',
'Accept': 'application/json'
}
response = requests.get(request_uri, headers = headers)
return response.json()
<!--NeedCopy-->