How to add a StoreFront server in Citrix Virtual Apps and Desktops
Use REST APIs to add a StoreFront server in your Citrix Virtual Apps and Desktops site.
Follow the prerequisites and examples to get started with this API.
You can make API requests using the PowerShell code, C# code, Python, or any tool that supports invoking the REST API.
Prerequisites to add a StoreFront server in Citrix Virtual Apps and Desktops
- Read the Learning journey for Citrix Virtual Apps and Desktops APIs section to ensure that you have the
bearer token
. - Get
siteid
from How to get site id API. - Make sure a Storefront Server host has been set up successfully with an accessible Url. Alternatively, provide the Storefront Server Id if it already has one (for example, once added to a site but removed later).
- Invoke the API described in this document from a client host or from the API exploration tab to add a new StoreFront server to the site.
Add a StoreFront server in your site using any REST API tool
Learn from the following example to add a StoreFront server in your Citrix Virtual Apps and Desktops site using any REST API tool.
Request
POST https://[DdcServerAddress]/cvad/manage/storefrontservers HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=utf-8
Authorization: CWSAuth bearer=<token-from-prerequisites>
Citrix-CustomerId: loy6oujtu6a4
Citrix-InstanceId: 22ded57c-0306-47e4-b6e8-fed6252759e1
{
"Name": "My-SF-A",
"Description": "Storefront Server A",
"Url": "https://portal-a.mysite.com/Citrix/StoreWeb",
"Enabled": true
}
<!--NeedCopy-->
Response
HTTP/1.1 200 OK
citrix-transactionid: f743c772...
content-Length: 1248
content-Type: application/json; charset=utf-8
date: "Thu, 20 Jan 2021 16:14:08 GMT"
<!--NeedCopy-->
Add a StoreFront server in your site using PowerShell
Learn from the following example to add a StoreFront server in your Citrix Virtual Apps and Desktops site using any PowerShell code.
function AddStoreFrontServer {
param (
[Parameter(Mandatory=$true)]
[string] $customerid,
[Parameter(Mandatory=$true)]
[string] $siteid,
[Parameter(Mandatory=$true)]
[string] $bearerToken,
[Parameter(Mandatory=$true)]
[string] $storefrontServerModel
)
$requestUri = "https://[DdcServerAddress]/cvad/manage/storefrontservers"
$headers = @{
"Accept" = "application/json";
"Content-Type"="application/json";
"Authorization" = "CWSAuth Bearer=$bearerToken";
"Citrix-CustomerId" = $customerid;
"Citrix-InstanceId" = $siteid;
}
$response = Invoke-RestMethod -Uri $requestUri -Method POST -Headers $headers -Body $storefrontServerModel
return $response
}
$customerId = "customer1"
$siteId = "61603f15-cdf9-4c7f-99ff-91636601a795"
$bearerToken = "ey1.."
$sfModel = @{
"Name" = "My-SF-A";
"Description" = "Storefront Server A";
"Url" = "https://portal-a.mysite.com/Citrix/StoreWeb";
"Enabled" = $true
}
$response = AddStoreFrontServer $customerid $siteid $bearerToken (ConvertTo-Json $sfModel)
<!--NeedCopy-->
Add a StoreFront server in your site using C# code
Learn from the following example to add a StoreFront server in your Citrix Virtual Apps and Desktops site using any C# code.
public static async Task<string> AddStoreFrontServer(
string customerid,
string siteid,
string bearerToken,
StoreFrontServerRequestModel model)
{
var requestUri = "https://[DdcServerAddress]/cvad/manage/storefrontservers";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.ParseAdd("application/json");
client.DefaultRequestHeaders.Add("Citrix-CustomerId", customerid);
client.DefaultRequestHeaders.Add("Citrix-InstanceId", siteid);
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("CWSAuth Bearer=" + bearerToken);
var jsonBody = JsonConvert.SerializeObject(model, new JsonSerializerSettings
{
Converters = new JsonConverter[] { new StringEnumConverter() }
});
var response = await client.PostAsync(requestUri, new StringContent(jsonBody, Encoding.UTF8, "application/json"));
if (response != null)
{
var content = await response.Content.ReadAsStringAsync();
return content;
}
return null;
}
}
<!--NeedCopy-->
Add a StoreFront server in your site using Python
Learn from the following example to add a StoreFront server in your Citrix Virtual Apps and Desktops site using Python.
import requests
def add_storefront_server(bearerToken, customerid, siteid, sfModel):
request_uri = "https://[DdcServerAddress]/cvad/manage/storefrontservers"
headers = {
'Authorization': 'CWSAuth Bearer=%s' % bearerToken,
'Citrix-CustomerId': customerid,
'Citrix-InstanceId': siteid,
'Content-Type': 'application/json',
'Accept': 'application/json'
}
payload = json.dumps(sfModel)
response = requests.post(request_uri, headers = headers, verify = False, data = payload)
return response.json()
<!--NeedCopy-->