Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Post Request with Invoke-WebRequest

Tags:

powershell

How would I use Invoke-WebRequest to post all these parameters

POST /token HTTP/1.1
Host: login.huddle.net
Content-Type: application/x-www-form-urlencoded

grant_type=authorization_code&client_id=s6BhdRkqt&redirect_uri=MyAppServer.com/receiveAuthCode&code=i1WsRn1uB
like image 551
Zz11 Avatar asked Jan 19 '17 15:01

Zz11


Video Answer


1 Answers

Here's how to convert that body into one which PowerShell can interpret.

$body = @{grant_type='authorization_code'
      client_id='s6BhdRkqt'
      redirect_uri='MyAppServer.com/receiveAuthCode'
      code='i1WsRn1uB'}
$contentType = 'application/x-www-form-urlencoded' 
Invoke-WebRequest -Method POST -Uri yourUrl -body $body -ContentType $contentType
like image 154
FoxDeploy Avatar answered Sep 30 '22 07:09

FoxDeploy