powershell http post REST API basic authentication

后端 未结 4 557
甜味超标
甜味超标 2020-12-13 20:17

I have basic authentatication working with REST API using curl:

curl -X POST  -H \'Accept: application/json\' -u user:password http://localhost/test/
         


        
4条回答
  •  时光取名叫无心
    2020-12-13 20:45

    Your code looks good, I would try adding HTTP_AUTHORIZATION header for $webrequest like this:

    $webRequest.Headers.Add("AUTHORIZATION", "Basic YTph");
    

    Where YTph would be the base64encoded string for username : password.

提交回复
热议问题