I am trying to invoke the API using this request. This request is working fine in Postman. But how can I convert it to PowerShell Invoke-RestMethod?
This is what I tried.
$token = "abcdef123456"
$url = "https://example.com/OVAV1/triggercalls/1"
$header = @{"Authorization"='abdcdef123456'}
$body =
{
"requestid": "<Echo back field>",
"templatename": "Line_Down",
"templateid": "abcde12345",
"noofrecords": 1,
"variableinfo": [
{
"<<MOBILE_NUMBER>>": "123456789",
"<<UNIQUE_CALL_IDENTIFIER>>": "A001",
"<<LinkType>>": "PRI",
"<<HostName>>": "HOSTNAME"
}
]
}
$request = Invoke-RestMethod -Uri $url -Headers $header -Body $body -ContentType "application/json" -Method Post
$request
I tried the JSON code in Postman. It's working fine. How can I use the same JSON code in PowerShell?