Invoke-WebRequest, POST with parameters

前端 未结 4 845
梦如初夏
梦如初夏 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:53

    This just works:

    $body = @{
     "UserSessionId"="12345678"
     "OptionalEmail"="MyEmail@gmail.com"
    } | ConvertTo-Json
    
    $header = @{
     "Accept"="application/json"
     "connectapitoken"="97fe6ab5b1a640909551e36a071ce9ed"
     "Content-Type"="application/json"
    } 
    
    Invoke-RestMethod -Uri "http://MyServer/WSVistaWebClient/RESTService.svc/member/search" -Method 'Post' -Body $body -Headers $header | ConvertTo-HTML
    

提交回复
热议问题