Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save clairecadman/750d645c71771274343aa9c1d33e77c4 to your computer and use it in GitHub Desktop.
Save clairecadman/750d645c71771274343aa9c1d33e77c4 to your computer and use it in GitHub Desktop.
Pipelines New App Example
$apiToken = $env:ApiToken
$username = $env:Username
$apiUrl = $env:ApiUrl
$appsUri = "https://$apiUrl/$Username/apps?apiToken=$ApiToken"
$appsCollection = Invoke-RestMethod -Uri $appsUri
Write-Output "Existing Apps"
Write-Output $appsCollection.apps.name
$jsonBody = @{Description = 'An Awesome New App'} | ConvertTo-JSON
$newAppName = 'NewApp004'
# $NewAppName var is in brackets because we don't want the ? character
# interpreted as a part of the variable name. It breaks the URI.
$params = @{
Uri = "https://$apiUrl/$username/apps/${newAppName}?apiToken=$apiToken"
Method = 'Put'
ContentType = 'application/json'
Body = $jsonBody
}
$returnValue = Invoke-RestMethod @params
Write-Output "App We Created"
Write-Output $returnValue.app.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment