Invoke-WebRequest, POST with parameters

前端 未结 4 838
梦如初夏
梦如初夏 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 17:04

    For some picky web services, the request needs to have the content type set to JSON and the body to be a JSON string. For example:

    Invoke-WebRequest -UseBasicParsing http://example.com/service -ContentType "application/json" -Method POST -Body "{ 'ItemID':3661515, 'Name':'test'}"
    

    or the equivalent for XML, etc.

提交回复
热议问题