Workspace Environment Management™ REST APIs
Sample codes of REST APIs for Workspace Environment Management™
Follow the sample codes on how to query all defined directory objects (formerly machine-level AD objects). The sample codes are available in C#, JavaScript (Fetch), JavaScript (XHR), PowerShell, Python (requests), and Python (httpx).
C# code
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Accept", "application/json");
client.DefaultRequestHeaders.Add("Citrix-TransactionId", "ab3e279b-f936-4abe-bfd5-cd24032e66a8");
client.DefaultRequestHeaders.Add("Authorization", "Bearer Your-Bearer-Token");
client.DefaultRequestHeaders.Add("Citrix-CustomerId", "Your-Customer-ID");
var response = await client.GetAsync("https://api.wem.cloud.com/services/wem/machines");
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
<!--NeedCopy-->
JavaScript code (Fetch)
const response = await fetch("https://api.wem.cloud.com/services/wem/machines", {
method: "GET",
headers: {
"Accept": "application/json",
"Citrix-TransactionId": "ab3e279b-f936-4abe-bfd5-cd24032e66a8",
"Authorization": "Bearer Your-Bearer-Token",
"Citrix-CustomerId": "Your-Customer-ID"
}
});
const data = await response.json();
console.log(data);
<!--NeedCopy-->
JavaScript code (XHR)
const xhr = new XMLHttpRequest();
xhr.open("GET", "https://api.wem.cloud.com/services/wem/machines");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Citrix-TransactionId", "ab3e279b-f936-4abe-bfd5-cd24032e66a8");
xhr.setRequestHeader("Authorization", "Bearer Your-Bearer-Token");
xhr.setRequestHeader("Citrix-CustomerId", "Your-Customer-ID");
xhr.onload = () => console.log(xhr.responseText);
xhr.send();
<!--NeedCopy-->
PowerShell code
$headers = @{
"Accept" = "application/json"
"Citrix-TransactionId" = "ab3e279b-f936-4abe-bfd5-cd24032e66a8"
"Authorization" = "Bearer Your-Bearer-Token"
"Citrix-CustomerId" = "Your-Customer-ID"
}
$response = Invoke-RestMethod -Uri "https://api.wem.cloud.com/services/wem/machines" `
-Method GET -Headers $headers
$response | ConvertTo-Json
<!--NeedCopy-->
Python code (requests)
import requests
headers = {
"Accept": "application/json",
"Citrix-TransactionId": "ab3e279b-f936-4abe-bfd5-cd24032e66a8",
"Authorization": "Bearer Your-Bearer-Token",
"Citrix-CustomerId": "Your-Customer-ID"
}
response = requests.get("https://api.wem.cloud.com/services/wem/machines", headers=headers)
print(response.json())
<!--NeedCopy-->
Python code (httpx)
import asyncio
import httpx
headers = {
"Accept": "application/json",
"Citrix-TransactionId": "ab3e279b-f936-4abe-bfd5-cd24032e66a8",
"Authorization": "Bearer Your-Bearer-Token",
"Citrix-CustomerId": "Your-Customer-ID"
}
async def main():
async with httpx.AsyncClient() as client:
response = await client.get(
"https://api.wem.cloud.com/services/wem/machines",
headers=headers
)
print(response.json())
asyncio.run(main())
<!--NeedCopy-->
Sample codes of REST APIs for Workspace Environment Management™
Copied!
Failed!