Skip to content

Instantly share code, notes, and snippets.

@RandomNoun7
Last active September 25, 2018 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save RandomNoun7/0451b0d64a74c31145beb256dc8817e0 to your computer and use it in GitHub Desktop.
Save RandomNoun7/0451b0d64a74c31145beb256dc8817e0 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