# Set the authentication request body
$body = @{
"grant_type" = "client_credentials"
"client_id" = $clientId
"client_secret" = $clientSecret
#"scope" = "https://api.cloud.com/auth/tenant/.default"
}
try {
# Make the REST API call using the Invoke-RestMethod cmdlet
$response = Invoke-RestMethod -Uri $authEndpoint -Method Post -Body $body
# Extract the bearer token from the response
$bearerToken = $response.access_token
Write-Host "Bearer Token Obtained Successfully: $bearerToken"
}
catch {
# Handle any errors that occurred during the API call
Write-Host "Failed to obtain bearer token: $($_.Exception.Message)"
}
Response:
{ "statusCode": 500, "message": "Internal server error", "activityId": "22372230-395f-40a5-883f-66c8e214d437" }
Question
Shishir Adhikari
Getting below response when sending below query - Powershell script:
$authEndpoint = "https://api-ap-s.cloud.com/m217v8vcnk97/root/tokens/clients"
# Set the authentication request body
$body = @{
"grant_type" = "client_credentials"
"client_id" = $clientId
"client_secret" = $clientSecret
#"scope" = "https://api.cloud.com/auth/tenant/.default"
}
try {
# Make the REST API call using the Invoke-RestMethod cmdlet
$response = Invoke-RestMethod -Uri $authEndpoint -Method Post -Body $body
# Extract the bearer token from the response
$bearerToken = $response.access_token
Write-Host "Bearer Token Obtained Successfully: $bearerToken"
}
catch {
# Handle any errors that occurred during the API call
Write-Host "Failed to obtain bearer token: $($_.Exception.Message)"
}
Response:
{ "statusCode": 500, "message": "Internal server error", "activityId": "22372230-395f-40a5-883f-66c8e214d437" }
Link to comment
0 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now