To test the Discovery service you need to get a token from the Token Service and then use the access_token to call the Discovery service (or other services you want to test).
Here is how I did this with PowerShell.
(you will need to add error handers)
I used this method so that I can automate the service installation and testing.
But Now I use
Dominic's Invoke-RestMethod
Test Live Site
#Live site
$TtmServiceUrl = "https://YourLiveSite.tridion.sdlproducts.com:8082"
$client_secret = "LiveSiteSecretKeyCode"
$access_token = Get-TtmCdAccessToken -TtmServiceUrl $TtmServiceUrl -client_secret $client_secret
Get-TtmcdDiscovery -TtmServiceUrl $TtmServiceUrl -access_token $access_token
Test Stage Site
#Stage site
$TtmServiceUrl = "https://YourStageSite.tridion.sdlproducts.com:8083"
$client_secret = "StageSiteSecretKeyCode"
$access_token = Get-TtmCdAccessToken -TtmServiceUrl $TtmServiceUrl -client_secret $client_secret
Get-TtmcdDiscovery -TtmServiceUrl $TtmServiceUrl -access_token $access_token
Get Access token
function Get-TtmCdAccessToken()
{
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,HelpMessage="Please enter the Ttm service url")]
[string]$TtmServiceUrl,
[Parameter(Mandatory=$True,HelpMessage="Please enter the client secret")]
[string]$client_secret,
[string]$client_id = 'cduser',
[string]$grant_type = 'client_credentials'
)
$h = [ordered]@{
client_id = $client_id
client_secret = $client_secret
grant_type = $grant_type
resources = "%2F"
}
$postdata = [system.String]::Join("&", $( $h.Keys | % { "$_=$($h.Item($_))" }) )
$webClient = New-Object System.Net.WebClient
$webClient.Headers.add('Cache-Control','no-cache')
$webClient.Headers.add('Content-Type','application/x-www-form-urlencoded')
$result = $webClient.UploadString("$TtmServiceUrl/token.svc",$postdata) | ConvertFrom-Json
return $result.access_token
}
Get Discovery Service
function Get-TtmcdDiscovery()
{
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,HelpMessage="Please enter the Ttm service url")]
[string]$TtmServiceUrl,
[Parameter(Mandatory=$True,HelpMessage="Please enter the access token")]
[string]$access_token
)
$Authorization = "Bearer $access_token"
$webClient = New-Object System.Net.WebClient
$webClient.Headers.add('Cache-Control','no-cache')
$webClient.Headers.add('Authorization',$Authorization)
$xmlresult = $webClient.DownloadString("$TtmServiceUrl/discovery.svc")
return $xmlresult
}