Jump to content
Welcome to our new Citrix community!
  • 0

Inconsistent Results from DaaS Applications API (/Applications)


Jeff Linkus1709164106

Question

I noticed I am getting duplicate applications if I don't set a limit of 1000 for this call and missing some other applications visible in DaaS. By duplicate I mean the same name and same ID. The total rows returned is correct.

For example, calling:

https://api-us.cloud.com/cvad/manage/Applications

, then calling:

https://api-us.cloud.com/cvad/manage/Applications?continuationToken={my_continuation_token}

,until the continuation token is null will give duplicate values.

If I specify a limit of 1000, I don't get any duplicates and can see the missing ones. I've seen this happen with Azure Data Factory and with a Python script created for troubleshooting. We have about 2,400 applications in total. If I use a limit of 250 or specify no limit, I get some duplicates/some missing, but the correct row count.

 

The general approach we take is make the initial call to the API, check for a continuation token, and then loop, calling with the token returned by each result set until it is null.

Is there an issue with my approach that somehow specifying 1000 resolves?

Link to comment

2 answers to this question

Recommended Posts

  • 0

There is a bug in this API, it has been reported to fix. Another option to get all applications is the application searching API https://developer-docs.citrix.com/en-us/citrix-daas-service-apis/citrix-daas-rest-apis/apis/#/Applications-APIs/Applications-DoApplicationSearch

 

Make the applications sorted by the application name in the search, and the name in the searching filter is always greater than the preview request, loop until the number of returned applications is less than the limit. Here is an example of a PowerShell script:

 

$customerId="..."
$instanceId="..."
$token="..." 

$fields="Id,Name,Description"
$limit = 1000
$transactionId=New-Guid
$uri = "https://api.cloud.com/cvad/manage/Applications/`$search?limit=$limit&fields=$fields"


$headers= @{
    "Citrix-CustomerId" = $customerId
    "Citrix-InstanceId" = $instanceId
    "Content-Type" = "application/json"
    "Accept-Encoding"   = "gzip"
    "Citrix-TransactionId" = $transactionId
    "Authorization" = "CWSAuth bearer=" + $token
}


$filter = @{
        "SearchFilters" = @(
            @{
                "Property" = "Name"
                "Value" = ""
                "Operator" = "GreaterThan"
            })
        "SortCriteria" = @{
            "Property"= "Name"
            "SortDirection"= "Ascending"
        }
}


$totalCount = 0
$totalCostTime = 0
$index = 1

while ($true)
{
    $start = Get-Date
    Set-Variable ProgressPreference SilentlyContinue; $response=Invoke-WebRequest -Method POST -Headers $headers -Uri $uri  -body ($filter| convertto-json -Depth 10)
    $end= Get-Date
    
    $applications = $response.Content | ConvertFrom-Json

    $costTime= (New-TimeSpan -Start $start -End $end).TotalSeconds
    $totalCostTime += $costTime
    $avgCostTime = $totalCostTime/$index

    $count = $applications.Items.Length
    $totalCount += $count

    Write-Output "$index, $transactionId, cost time: $costTime, avg cost time: $avgCostTime, total cost time: $totalCostTime, count: $count/$totalCount, endpoint: $uri"

    if ($applications.Items.Length -lt $limit)
    {
       break
    }

    $filter.SearchFilters[0].Value = $applications.Items[$limit-1].Name
    $index = $index+1
}

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...