AppSync: How to create a REST API script to connect to an AppSync server using Powershell

Resumo: The purpose of this KB is to provide a sample Powershell REST api script that shows how to connect to the AppSync server and return XML output as a file.

Este artigo aplica-se a Este artigo não se aplica a Este artigo não está vinculado a nenhum produto específico. Nem todas as versões do produto estão identificadas neste artigo.

Instruções

The following script can be used to connect to any AppSync server and return details relating to all the Service Plans created on the server. This is a simplified example and should be modified to suit each users specific requirements.

add-type @"
    using System.Net;
    using System.Security.Cryptography.X509Certificates;
    public class TrustAllCertsPolicy : ICertificatePolicy {
        public bool CheckValidationResult(
            ServicePoint srvPoint, X509Certificate certificate,
            WebRequest request, int certificateProblem) {
            return true;
        }
    }
"@
 
#Get Login creds and target server
 
$user = Read-Host 'Enter the Appsync Administrator User Id'
$pass = Read-Host 'Enter the Appsync Administrator Password'
$ashost = Read-Host 'Enter the name or IP address of the Appsync Server'
 
 
#create Login URL
 
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
[string] $loginuri = "https://" + $ashost + ":8444/cas-server/login"
$request = Invoke-WebRequest -Uri $loginuri -SessionVariable session
 
 
#Login to the CAS server
$form = $request.Forms[0]
$form.Fields["username"] = $user
$form.Fields["password"] = $pass
 
[string] $loginuri = "https://" + $ashost + ":8444/cas-server/login"+ $form.Action
 
$request = Invoke-WebRequest -Uri $loginuri -SessionVariable session -Body $form.Fields
 
#Execute the Rest request
 
$url= "https://" + $ashost + ":8445/appsync/rest/types/servicePlan/instances"
 
$restrequest = Invoke-RestMethod -method GET -Uri $url -WebSession $session -outfile .\output1.xml
 

Produtos afetados

AppSync

Produtos

AppSync
Propriedades do artigo
Número do artigo: 000158365
Tipo de artigo: How To
Último modificado: 18 set. 2025
Versão:  5
Encontre as respostas de outros usuários da Dell para suas perguntas.
Serviços de suporte
Verifique se o dispositivo está coberto pelos serviços de suporte.