Files
Powershell/GCP/Publish-PubSub.ps1
2025-06-03 09:41:27 +02:00

30 lines
1.0 KiB
PowerShell

$ProjectId = "ari-prj-np-mdf-001"
$TopicName = "MindFlow:publish"
$Message = "Vendredi 23 mai à 12:00"
$AccessToken = "ya29.a0AW4Xtxhb0o5hP7lkY1kH6ZplZy2hUlfLP1l7QDQlv8th758tD2T-GSL3fKw65zQGr1ilrBBpgn9lM3B4ZhZTmebQgwPykr6gW_MbhLDr7RWmY5mBZXY3EPz9hYjaWa4qEbJDyp1NHsSCKeYWQ-9n24jMNRjeqzxPH50qQIBV2wH7lgaCgYKAToSARESFQHGX2MiqPoqBQZYeAWTQqbEYyLehA0181"
$apiUrl = "https://pubsub.googleapis.com/v1/projects/$ProjectId/topics/$TopicName"
$response = $null
$headers = @{
"Authorization" = "Bearer $AccessToken"
"accept" = "application/json"
"Content-Type" = "application/json"
}
# Define the request body (if needed)
$body = @{
messages= @(
@{
data = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($message))
attributes = @{
subject = "ARI_202209_029"
}
}
)
} | ConvertTo-Json -Depth 10
# Make the API call using Invoke-RestMethod
$response = Invoke-RestMethod -Uri $apiUrl -Method Post -Headers $headers -Body $body
# Output the response
$response