AppSync: Jak utworzyć skrypt interfejsu API REST w celu nawiązania połączenia z serwerem AppSync przy użyciu programu PowerShell

Summary: Celem tej bazy wiedzy jest udostępnienie przykładowego skryptu interfejsu API REST programu PowerShell, który pokazuje, jak nawiązać połączenie z serwerem AppSync i zwrócić dane wyjściowe XML jako plik. ...

This article applies to This article does not apply to This article is not tied to any specific product. Not all product versions are identified in this article.

Instructions

Poniższy skrypt może służyć do łączenia się z dowolnym serwerem AppSync i zwracania szczegółów dotyczących wszystkich planów serwisowych utworzonych na serwerze. Jest to uproszczony przykład i powinien zostać zmodyfikowany w celu dostosowania do specyficznych wymagań każdego użytkownika.

add-type @"
za pomocą System.Net;
    przy użyciu System.Security.Cryptography.X509Certificates;
    klasa publiczna TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
        } }
"@

#Get Certyfikaty logowania i serwer

docelowy$user = Read-Host 'Wprowadź identyfikator użytkownika administratora Appsync'
$pass = Read-host 'Wprowadź hasło administratora Appsync'
$ashost = Read-Host 'Wprowadź nazwę lub adres IP serwera Appsync'


#create Adres URL

logowania[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

[ciąg] $loginuri = "https://"      + $ashost + ":8444/cas-server/login"
$request = Invoke-WebRequest -Uri $loginuri -SessionVariable session#Login do


serwera
CAS$form = $request. Formularze[0]
$form. Fields["nazwa użytkownika"] = $user
$form. Pola["hasło"] = $pass

[ciąg] $loginuri = "https://"    + $ashost + ":8444/cas-server/login"+ $form. Akcja
 
$request = Invoke-WebRequest -uri $loginuri -SessionVariable session -Body $form. Pola
 
#Execute żądanie
 
Rest$url= "https://" + $ashost + ":8445/appsync/rest/types/servicePlan/instances"
 
$restrequest = Invoke-RestMethod -method GET -Uri $url -WebSession $session -outfile .\output1.xml
 

Affected Products

AppSync

Products

AppSync
Article Properties
Article Number: 000158365
Article Type: How To
Last Modified: 18 Sept 2025
Version:  5
Find answers to your questions from other Dell users
Support Services
Check if your device is covered by Support Services.