Hi,
I’m trying to add an SMS alert to a script using ClickSend however having an issue with getting powershell to output the required format in JSON i think, i get a response saying “The remote server returned an error: (400) Bad Request”
I suspect the issue is me not correctly formating the body of the message inline with their docs here - ClickSend v3 API
$pwd = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f 'username', 'password')))
$body = @{
messages = @{
from = 'sender'
to = '+447800000000'
body = 'SMS message body'
}
}
$json = ConvertTo-Json -InputObject $body
$smsresponse = Invoke-RestMethod -Headers @{ Authorization = ("Basic {0}" -f $pwd) } -uri 'https://rest.clicksend.com/v3/sms/send' -Method Post -Body $json -ContentType 'application/json'
Any help adjusting my script would be much appreciated.
Regards,
Jamie