Invoke-WebRequest, POST with parameters

前端 未结 4 847
梦如初夏
梦如初夏 2020-11-29 16:43

I\'m attempting to POST to a uri, and send the parameter username=me

Invoke-WebRequest -Uri http://example.com/foobar -Method POST
4条回答
  •  我在风中等你
    2020-11-29 16:59

    Single command without ps variables when using JSON as body {lastName:"doe"} for POST api call:

    Invoke-WebRequest -Headers @{"Authorization" = "Bearer N-1234ulmMGhsDsCAEAzmo1tChSsq323sIkk4Zq9"} `
                      -Method POST `
                      -Body (@{"lastName"="doe";}|ConvertTo-Json) `
                      -Uri https://api.dummy.com/getUsers `
                      -ContentType application/json
    

提交回复
热议问题