Instantly share code, notes, and snippets.

Embed
What would you like to do?
write-verbose "Create App Instance"
$userAgent = "DR UCWA App"
$EndpointID = "75d0449f-aa09-4f5d-add5-eeefc518b337"
try{
$postparams = @{UserAgent=$userAgent;EndpointId=$EndpointID;Culture="en-US"} | ConvertTo-JSON
$data = Invoke-WebRequest -Uri "$rootappurl" -Method POST -Body "$postparams" -Headers @{"Authorization"="Bearer $authcwt"} -ContentType "application/json" -UseBasicParsing
$appurl = $(($data.content | ConvertFrom-JSON)._links.self.href)
$appurl = "$($rootappurl.split("/")[0..2] -join "/")$(($data.content | ConvertFrom-JSON)._links.self.href)"
$meurl = $(($data.Content | ConvertFrom-JSON)._embedded.me._links)
$peopleurl = $(($data.Content | ConvertFrom-JSON)._embedded.people._links)
$appid = $appurl.split("/")[-1]
$operationID = (($data.content | ConvertFrom-JSON)._embedded.communication | GM -Type Noteproperty)[0].name
# Need to allow HTML messages to be posted
$postparams = @{"supportedMessageFormats"="Plain","Html"} | ConvertTo-JSON
$data = Invoke-WebRequest -Uri "$rootappurl/$appid/communication/makeMeAvailable" -Method POST -Body $postparams -Headers @{"Authorization"="Bearer $authcwt"} -ContentType "application/json" -UseBasicParsing
}catch{
write-output "Unable to create application instance"
exit 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment