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

Can't get a results of "test machine catalog" thru API


Martin Kovac1709158740

Question

Hello,

 

I need to create a "Test Machine Catalog" report.

Thru following PS code I'm able to send a request to ctx cloud to initiate a Test on particular machine catalog.

$response = Invoke-WebRequest "https://api.cloud.com/cvadapis/$siteId/MachineCatalogs/$catalogId/$test" -Headers $Headers

If I want to get a result thru command:

 

$responsee = Invoke-WebRequest "https://api.cloud.com/cvadapis/$siteId/MachineCatalogs/$catalogIdEU/TestReport" -Headers $Headers

I always get an error, regardless of time I launch above command.  If I run the command after 15 min I get the same error:

 

Invoke-WebRequest : { "ErrorMessage": "", "SdkErrorId": "UnknownError", "ErrorType": "ObjectNotFoundException", "ErrorDetails": "Transaction ID: 6f92c176-cc67-4548-9e62-3ede7f3a9a2f\r\nAction Name: 
GetMachineCatalogTestReport\r\n\r\nAn error occurred. Contact Citrix Technical Support, and provide the transaction ID above.\r\n\r\nException:\r\n DesktopStudio_ErrorId : UnknownError\r\n ErrorCategory 
: ObjectNotFound\r\n Error Source : CitrixOrchestration\r\n \r\n", "SupportLink": null, "ErrorReportXml": null, "ErrorReport": null }
At line:1 char:14
+ ... responsee = Invoke-WebRequest "https://api.cloud.com/cvadapis/$siteId ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

 

When I try to do it asynchronously:

 

$response = Invoke-WebRequest "https://api.cloud.com/cvadapis/$siteId/MachineCatalogs/$catalogId/$test`?async=true" -Headers $Headers

and by checking the job I always get the overalpercentage equal to 0 however status shows me : completed

 

$res2 = Invoke-WebRequest "https://api-us.cloud.com/cvadapis/$siteID/Jobs/jobID"

 

$res2.Content
{
  "Id": "9ea5246c-6e6d-4e5d-86e3-0dfd6c6eec56",
  "Type": "GetMachineCatalogDetails",
  "OverallProgressPercent": 0,
  "IsCancellable": false,
  "Parameters": [],
  "SubJobs": [],
  "Status": "Complete",

 

after all, I can't get an relevant result from job:

 

$res = Invoke-WebRequest "https://api-us.cloud.com/cvadapis/$siteID/Jobs/$jobID/results"

it shows me a results but not from the test of machine catalog I have initiated. It shows me always the result of some "morning" test that was not initiated by me even if I run the test X times.

 

 

 

Somebody knows how to get a result from running job or generally how to get an report from "Test machine catalog" ?

 

Any help would be appreciated. 

Link to comment

6 answers to this question

Recommended Posts

  • 0

It appears the catalog test failed to be created or started.

Could you please try the following PowerShell command which does the same catalog test:

Start-EnvTestTask -TestSuiteId "Catalog" -TargetIdType "Catalog" -TargetId <catalogId>

See https://developer-docs.citrix.com/projects/citrix-virtual-apps-desktops-service-sdk/en/latest/EnvTest/Start-EnvTestTask/ for more detail about this cmdlet.

If the PowerShell command is successful, it could be an API issue. Otherwise we will follow the PowerShell error message to triage.

Link to comment
  • 0

Hello,

 

thank you for your reply.

 

On first time I've tried to initiate a catalog test by way you provided, but I had an issue with defining the commands correctly, therefore I have decided to go by API way.

 

My code was:

 

New-EnvTestDiscoveryTargetDefinition -BearerToken $GLOBAL:XDAuthToken -TargetId "24c92ca4-d114-40cb-b8d7-180978016d69" -TargetIdType "Catalog" -TestSuiteId "Catalog" | Set-Variable -Name "testTarget0"

Get-Variable -Name @("testTarget0") -ValueOnly | Start-EnvTestTask -BearerToken ******** -RunAsynchronously 

 

This code was taken as a hint from page: 

 

https://discussions.citrix.com/topic/406191-powershell-commands-to-generate-mcs-catalog-html-report-test-machine-catalog-in-xendesktop-715/

 

Anyway I get an error:

 

New-EnvTestDiscoveryTargetDefinition : An invalid URL was given for the service.  The value given was ''.
    The reason given was: Failed to connect to back-end server 'localhost' on port 80 using binding WSHttp. The server may be off-line or may not be running the appropriate service
	There was no endpoint listening at http://localhost/Citrix/EnvTestServiceContract/v1 that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if 
present, for more details.
	Unable to connect to the remote server
	No connection could be made because the target machine actively refused it [::1]:80.
At line:4 char:1
+ New-EnvTestDiscoveryTargetDefinition -BearerToken $GLOBAL:XDAuthToken ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [New-EnvTestDiscoveryTargetDefinition], InvalidOperationException
    + FullyQualifiedErrorId : Citrix.XDPowerShell.Status.CommunicationError,Citrix.EnvTest.Sdk.Commands.NewEnvTestDiscoveryTargetDefinitionCommand
 
Start-EnvTestTask : An invalid URL was given for the service.  The value given was ''.
    The reason given was: Failed to connect to back-end server 'localhost' on port 80 using binding WSHttp. The server may be off-line or may not be running the appropriate service
	There was no endpoint listening at http://localhost/Citrix/EnvTestServiceContract/v1 that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if 
present, for more details.
	Unable to connect to the remote server
	No connection could be made because the target machine actively refused it [::1]:80.
At line:6 char:50
+ ... ValueOnly | Start-EnvTestTask -BearerToken ******** -RunAsynchronousl ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Start-EnvTestTask], InvalidOperationException
    + FullyQualifiedErrorId : Citrix.XDPowerShell.Status.CommunicationError,Citrix.EnvTest.Sdk.Commands.StartEnvTestTaskCommand

I think it was because I omitted the following property, which is maybe important, but for me is confused because I don't want to use on-premise farm but cloud : 

-AdminAddress "host.domain.org:80"

I'm not able to found out what exactly  adminaddress property means. In on-premise terminology it's a DDC IP or hostname but I don't know what does it mean in CLOUD.

Link to comment
  • 0

In Cloud environment, you need to download and install the Citrix Remote PowerShell SDK to manage a site. Most cmdlets are the same but the initial steps are a little different. See a brief introduction and user guide at:

 

https://www.citrix.com/blogs/2016/07/01/introducing-remote-powershell-sdk-v2-for-citrix-cloud/#

https://docs.citrix.com/en-us/citrix-virtual-apps-desktops-service/sdk-api.html
 

With the Remote SDK, the -AdminAdress property points to the Cloud Connector address if present. By default it need not be specified.

Link to comment
  • 0

I'm already using the Remote PS SDK and I have created several "cloud" scripts that are running correctly with correct authentication using bearer token so don't worry about downloading remote PS SDK.

 

 

Finally I found that Start-EnvTestTask cmdlet together with rest Env commands are not a part of Remote PS SDK commands.

They are part of Citrix.EnvTest.Admin.V1 PS_snapin which are used for on-prem farms so can't be used for connection to cloud env. This is the reason why I get an error:

 

An invalid URL was given for the service.  The value given was ''.
    The reason given was: Failed to connect to back-end server 'localhost' on port 80 using binding WSHttp.

 

So only chance to make a "Test machine catalog" in cloud env. is using CLOUD API, which I'm using correctly as well, but didn't get the relevant response. The job object returns buggy data.

This is something on Citrix should take a look.

I'm using cloud API to get and set info in cloud farm without any issue but "Test Machine Catalog" is simply not working.

Link to comment
  • 0

Test Machine Catalog (asynchronously):

 

$responseAP = Invoke-WebRequest "https://api.cloud.com/cvadapis/$siteId/MachineCatalogs/$catalogIdEU/$test`?async=true" -Headers $Headers -Verbose

Details of response:

 

PS H:\> $responseAP.Headers

Key                    Value                                                                                                                   
---                    -----                                                                                                                   
Pragma                 no-cache                                                                                                                
Vary                   Accept-Encoding                                                                                                         
Citrix-TransactionId   32109401-7e5e-4d25-a017-44e09c229fb6                                                                                    
X-Content-Type-Options nosniff                                                                                                                 
X-Cache                CONFIG_NOCACHE                                                                                                          
X-Azure-Ref            0xu9KYQAAAACzPwQiYX9dSa+g8W6GdyFvQlJVMzBFREdFMDQwOQA1ZmUzZTE0Yi05MTk0LTQxYWEtYmIxNS00MzgwM2Y1ZWQwZTE=                   
Content-Length         0                                                                                                                       
Cache-Control          no-store, must-revalidate, no-cache                                                                                     
Date                   Wed, 22 Sep 2021 08:56:39 GMT                                                                                           
Location               https://api-us-eastus2.cloud.com/cvadapis/SiteID_Hash/Jobs/eb0760ba-d74b-4e54-be22-70991878e347

 

So I want to know the status/info about running job:

$AllJobs= Invoke-WebRequest "https://api-us-eastus2.cloud.com/cvadapis/SiteID_hash/Jobs/eb0760ba-d74b-4e54-be22-70991878e347"  -Headers $Headers -Verbose

but I get:

 

VERBOSE: GET https://api-us-eastus2.cloud.com/cvadapis/SiteID_hash/Jobs/eb0760ba-d74b-4e54-be22-70991878e347 with 0-byte payload


Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.
At line:1 char:11
+ $AllJobs= Invoke-WebRequest "https://api-us-eastus2.cloud.com/cvadapi ...
+           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

 

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