developer-docs.citrix.com
Open in
urlscan Pro
2a05:d014:275:cb01:2ef6:2f8a:9434:a758
Public Scan
Submitted URL: https://launch.citrix.com/OTg5LUJITy0wNDYAAAGAyP1XD3gfBWg4gdDoQdVhqjbvDYIM-YB5hv5gwSERgpezkTTUwEfblHv6vMg2fhzAbDTzMHg=
Effective URL: https://developer-docs.citrix.com/projects/access-monitor-service-data-citrix-cloud/en/latest/%20%20?utm_campaign=WW-1021-VADservi...
Submission: On November 16 via manual from IN — Scanned from DE
Effective URL: https://developer-docs.citrix.com/projects/access-monitor-service-data-citrix-cloud/en/latest/%20%20?utm_campaign=WW-1021-VADservi...
Submission: On November 16 via manual from IN — Scanned from DE
Form analysis
1 forms found in the DOMName: search —
<form class="md-search__form" name="search">
<input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" data-md-state="active" required="">
<label class="md-search__icon md-icon" for="__search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path
d="M9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.44,13.73L14.71,14H15.5L20.5,19L19,20.5L14,15.5V14.71L13.73,14.44C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3M9.5,5C7,5 5,7 5,9.5C5,12 7,14 9.5,14C12,14 14,12 14,9.5C14,7 12,5 9.5,5Z">
</path>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z"></path>
</svg>
</label>
<button type="reset" class="md-search__icon md-icon" aria-label="Clear" data-md-component="search-reset" tabindex="-1">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"></path>
</svg>
</button>
</form>
Text Content
Skip to content | Developer Docs Accessing Monitor Service Data in Citrix Cloud Type to start searching Accessing Monitor Service Data in Citrix Cloud * Home Home Table of contents * Supported API Gateway endpoints * HTTP error codes * Generate Citrix Cloud Bearer Token * Method 1: XenApp and XenDesktop Remote PowerShell SDK * Method 2: Citrix Cloud API: * Use cases and walk-through of OData APIs ands PowerShell SDK * Questions? Was this article helpful? Provide Feedback Table of contents * Supported API Gateway endpoints * HTTP error codes * Generate Citrix Cloud Bearer Token * Method 1: XenApp and XenDesktop Remote PowerShell SDK * Method 2: Citrix Cloud API: * Use cases and walk-through of OData APIs ands PowerShell SDK ACCESS MONITOR SERVICE DATA USING THE ODATA V4 ENDPOINT IN CITRIX CLOUD¶ You can now query the Monitor Service data using the OData Version 4 endpoint based on ASP .Net Web API. Customers can now run aggregation queries on the Monitor Service data; this feature was not available in OData Version 3 or earlier. Note Accessing Monitor Service data using the OData v4 endpoint in Citrix Cloud is currently under preview. A Citrix Cloud customer can access the data with the V4 endpoint after authentication using the Citrix Cloud username and authentication token or the bearer token. Note To ensure optimal performance and resource utilization of the Delivery Controller, one OData query is permitted per customer at a time. Query time out is 30 seconds. If you exceed the limit of one request at a time, a 429 Too Many Requests response status code is returned. SUPPORTED API GATEWAY ENDPOINTS¶ * US region: https://api-us.cloud.com/monitorodata * EU region: https://api-eu.cloud.com/monitorodata * AP-S region: https://api-ap-s.cloud.com/monitorodata Note * The "https://{Customer_Id}.xendesktop.net/Citrix/monitor/odata/v4/data" URL is replaced with "https://{ApiGatewayEndpoint}". The HTTP header "Customer" is now replaced with "Citrix-CustomerId". * For Government and Japan (https://.apps.citrixworkspacesapi.jp) customers, the existing URLs and header name (Customer) remain unchanged. HTTP ERROR CODES¶ See HTTP error codes to know about the various error codes and their descriptions. GENERATE CITRIX CLOUD BEARER TOKEN¶ You can obtain the bearer token using either of the following methods: METHOD 1: XENAPP AND XENDESKTOP REMOTE POWERSHELL SDK¶ 1. Download the Remote PowerShell SDK from here. 2. Install the SDK on any computer in your resource location. 3. Open a PowerShell command prompt. (administrator rights are not required) 4. Add the Citrix snap-ins: asnp citrix*. 5. Execute the cmdlet, Get-XdAuthentication, it prompts you for Citrix Cloud authentication. 6. On successful authentication, the bearer token is stored in the current PowerShell session. 7. Execute the cmdlet, Get-Variable to list all the variables in the current PowerShell session. 8. The list contains a variable, GLOBAL:XDAuthToken containing bearer token as value. 9. Copy the bearer token value to be used in the OData query. METHOD 2: CITRIX CLOUD API:¶ You may obtain the bearer token using the Citrix Cloud APIs. For more information on the steps, see https://developer.cloud.com/getting-started For the details of the Monitor Service schema, see Monitor Service Schema. To determine the values returned by the Monitor Service OData API, see Citrix.Monitor.Model. The list of URLs for available data sets is available at URLs for Available Data Sets. Replace http://{dc-host}/Citrix/Monitor/OData/v4/Data with "https://{ApiGatewayEndpoint}". USE CASES AND WALK-THROUGH OF ODATA APIS ANDS POWERSHELL SDK¶ Here's a video explaining the various use cases of OData APIs and PowerShell SDK used in Citrix Virtual Apps and Desktops. ACCESS METHODS¶ ACCESS USING MS EXCEL POWERQUERY¶ 1. Open Excel (Excel 2016 has PowerQuery inbuilt. If you are using earlier versions of Excel, install PowerQuery, see https://www.microsoft.com/en-in/download/details.aspx?id=39379)) 2. In Excel 2016, go to Data menu > Get & Transform group > New Query > From Other Sources > click Blank Query 3. In the Query Editor window, go to Home menu > Query group > click Advanced Editor. 4. In the Advanced Editor window, type the following query: let Source = OData.Feed ( "https://{ApiGatewayEndpoint}/Machines", null, [ Headers = [ #”Authorization” = "<YourToken>", #"Citrix-CustomerId" = "<YourCustomerId" ] ] ) in Source Replace <YourCustomerId> and <YourToken> with the values of CustomerID and bearer token you obtained as described in the Generate the Citrix Cloud Bearer Token section. Make sure that the <YourToken> is in the format, “CWSAuth bearer= ”. Once the No Syntax errors have been detected is displayed in the bottom of the window, click Done. 5. In case of first login, a Please specify how to connect message is displayed. Click Edit Credentials, the Access an OData feed window appears. Make sure that the Anonymous tab and the base URL are selected and click Connect. 6. Upon successful authentication, the results are displayed as a table. In this example, the table lists all the Machines of the CustomerId. If the authentication fails, either the bearer token or the CustomerId might be invalid. Please verify the same and try again. ACCESS USING C# CLIENT LIBRARY¶ Use a Simple.OData.Client to create a C# client for an OData v4 endpoint. For information about installation of its Nuget Package, see https://github.com/object/Simple.OData.Client/wiki/Getting-started-with-Simple.OData.Client. Install the package using the Nuget Package Manager: Install-Package Simple.OData.Client After installation, use the package with the following command: using Simple.OData.Client; As the OData query in the Cloud requires the Citrix Cloud authentication, the OData clients must pass the bearer token (as documented in the Generate Citrix Cloud Bearer Token section) and the CustomerId. Set up the headers as follows, before creating the OData query: ODataClientSettings settings = new ODataClientSettings(); settings.BeforeRequest += request => { request.Headers.Add("Authorization", "<BearerToken>"); request.Headers.Add("Citrix-CustomerId", "<customerId>"); }; settings.BaseUri = new Uri("https://{ApiGatewayEndpoint}"); client = new ODataClient(settings); Data can be retrieved by using async methods. This example lists all the Machines public static async void GetMachines() { var machines = await client.FindEntriesAsync("Machines"); foreach(var machine in machines) { Console.WriteLine(machine["Id"]); } } ACCESS USING POWERSHELL¶ Below is a sample OData query triggered from PowerShell with the headers initialized and the Raw XML output redirected to a file: PS C:\> $headers = @{"Authorization" = "<BearerToken>”; "Citrix-CustomerId" = "<Your Customer Id>"} PS C:\> $url = https://{ApiGatewayEndpoint}/Users PS C:\> $result = Invoke-WebRequest -Uri $url -Headers $headers PS C:\> $result.Content > <Path-to-Output-File> ACCESS USING OTHER REST CLIENTS (EX. POSTMAN CHROME EXT.)¶ 1. Install Postman from Chrome extensions. See https://chrome.google.com/webstore. 2. Launch the application. 3. Select GET in the dropdown and type in the URL to request. 4. Insert headers with your token and customerId. Click Send. 5. If authentication is successful, response data is seen in the Response section of Postman. AGGREGATION QUERIES IN ODATA V4¶ Aggregation queries were not supported in OData Version 3 and earlier. It is supported in OData Version 4. As per OData documentation, aggregation can be done using the $apply=aggregate() field. Below are few examples that show data aggregation. Use them after https://{ApiGatewayEndpoint}/ ?$apply=aggregate([column to aggregate] with [aggregation type] as [column to aggregate]) Aggregation Types: * Count : Machines?$count=true This gives the total number of machines. * Sum : Sessions?$apply=aggregate(SessionType with sum as SessionType) This gives the sum of session types in Sessions. * Min : Machines?$apply=aggregate(LifecycleState with min as LifecycleState) This gives the minimum of all the life cycle states. ODATA PAGINATION¶ Citrix Monitor supports OData pagination. All OData v4 endpoints return a maximum of 100 records per page with a link to the next 100 records. The following PowerShell script fetches applications in batches of 100 records using Citrix Cloud authentication following the @odata.nextLink property in the response. $customerId = "[customerid]" $api = "https://{ApiGatewayEndpoint}" $endpoint = "$api/Applications" $bearer = "CWSAuth bearer=[token]" $headers = @{'Citrix-CustomerId'=$customerId;'Authorization'=$bearer} $results = Invoke-RestMethod $endpoint -Headers $headers -Verbose Write-Host “Number of items returned in the first call : ”, $results.value.Count while($results.'@odata.nextLink' -ne $null) { $results = Invoke-RestMethod $results.'@odata.nextLink' -Headers $headers -Verbose Write-Host "Number of items returned in next call : ", $results.value.Count } Was this article helpful? Provide Feedback Privacy and legal terms | Cookie preferences © 1999-2020 Citrix Systems, Inc. All rights reserved.