简体   繁体   中英

"The API-version is not valid

I'm trying to make a PowerShell script, which will be run from a power-automate flow, and which in turn is supposed to call different power-automate flows via a Http request, the Url used here is generated by power-automate flow. My issue arise when I try to do

Invoke-Webrequest -Uri https://xxxx-xxx.westeurope.logic.azure.com:xxx/workflows/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/triggers/manual/paths/invoke?api-version=2016-06-01%26sp=%2Ftriggers%2Fmanual%2Frun%26sv=1.0%26sig=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxx -Method POST -Body $PostParams

And when this is run, I get the error of

The Api-Version '2016-06-01&sp=/triggers/manual/run&sv=1.0&sig=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx-rmZzrBfsAvjCc' is not valid. It goes on to suggest some valid ones, which among them are '2016-06-01'.

I have tried removing %26sp, which also did not work. I've tried searching up any information regarding Api-version is not valid, but yielded no result.

I think you should do Invoke-RestMethod

$request = 'https://put_here_your_uri'
$result = Invoke-RestMethod -Method Post -Uri $request

And if you have header like bearer token add -Headers $headers

$headers = @{
    'Authorization' = 'bearer HERE_BEARER_TOKEN'
}

Turns out, after quite a bit of back and forth and with an external answer I found out the URL had to be encoded before I could use it in my code

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM