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

function SearchSessionsByUser


Mariusz Gal

Question

Hi, I have a question about function SearchSessionsByUser  found at CC REST API doc site:

 

The function:

function SearchSessionsByUser {
    param (
        [Parameter(Mandatory=$true)]
        [string] $customerid,
        [Parameter(Mandatory=$true)]
        [string] $siteid,
        [Parameter(Mandatory=$true)]
        [string] $bearerToken,
        [Parameter(Mandatory=$true)]
        [string] $body
    )
    $requestUri = https://api-us.cloud.com/cvad/manage/Sessions/$search
    $headers = @{
        "Accept" = "application/json";
        "Authorization" = "CWSAuth Bearer=$bearerToken";
        "Citrix-CustomerId" = $customerid;
        "Citrix-InstanceId" = $siteid;
    }
    $response = Invoke-RestMethod -Uri $requestUri -Method POST -Headers $headers -Body $body
    return $response
}

the defined $body at the moment is: 

$body = @"
{
   "SearchFilters": [
        {
          "Property": "SessionState",
          "Value": "Disconnected",
          "Operator": "Equals"
         }
    ]
}
"@ 

the request:

$response = SearchSessionsByUser -CustomerID $customerid -SiteID $CCSiteID -bearerToken $CCAccessToken -body $body 

I have my $cutomerId, $CCsiteID and $CCAccessToken that I already use with another function without any problems, however when I want to get that $response from that function above I get an error:

Quote

Invoke-RestMethod : { "statusCode": 500, "message": "Internal server error"...
+ ... $response = Invoke-RestMethod -Uri $requestUri -Method POST -Headers  ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

 

does anyone have any idea on what could be wrong? 

 

Link to comment

2 answers to this question

Recommended Posts

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...