AppSync: How to create a REST API script to connect to an AppSync server using Powershell
Summary: 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.
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
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
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
Affected Products
AppSyncProducts
AppSyncArticle 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.