I want to pass a few body parameters using x-www-form-urlencoded format using powershell invoke-restmethod. Do not that this is working fine in PostMan. My code for this is below but is not working. How do I accomplish this in powershell?
$param = [System.Web.HttpUtility]::UrlEncode("channel:channelID
Content-Type:application/x-www-form-urlencoded
limit:50")
$uri="https://MySlackWebsite.com/api/channels.history"
$test2 = Invoke-RestMethod -Method POST -Uri $uri -Headers $headerJson -Body $param
$req = [System.Web.HttpUtility]::UrlEncode("channel:ChangelID Content-Type:application/x-www-form-urlencoded limit:50") $uri="https://slackserver.com/api/channels.history" $test2 = Invoke-RestMethod -Method POST -Uri $uri -Headers $headerJson -Body $req -ContentType "application/x-www-form-urlencoded"
– JackleTackle Apr 24 '19 at 16:09