Help adding to the body of a web request using powershell v2

I am currently working on a project where I need to use a web api. I see the invoke-webservice cmdlet in 3.0 but the servers im working on have 2.0 and I cant upgrade them without the customers approval. With that said I am trying to get this to work using the .net way and im having issues adding the body of the request. Below is my code that I have so far and I can add the header and url but when I do a GM on $request I don't see anything for body.

Would anybody know how to add the body? I need to add a json object to the body of the request.

$url = "https://remoteserver:8443/oo/rest/roles"

$request = [System.Net.WebRequest]::Create($url)

$request.Headers.Add("Authorization","Basic <Account>")

$request.Method= "Get"

$request.GetResponse()

April 25th, 2015 2:34pm

Here is one way to set up a conversation.

http://stackoverflow.com/questions/22921529/powershell-webrequest-post

Free Windows Admin Tool Kit Click here and download it now
April 25th, 2015 3:08pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics