Quantcast
Channel: How to parse JSON from the Invoke-WebRequest in PowerShell? - Stack Overflow
Viewing all articles
Browse latest Browse all 4

How to parse JSON from the Invoke-WebRequest in PowerShell?

$
0
0

When sending the GET request to the server, which uses self-signed certificate:

add-type @"    using System.Net;    using System.Security.Cryptography.X509Certificates;    public class TrustAllCertsPolicy : ICertificatePolicy {        public bool CheckValidationResult(            ServicePoint srvPoint, X509Certificate certificate,            WebRequest request, int certificateProblem) {            return true;        }    }"@[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy$RESPONSE=Invoke-WebRequest -Uri https://yadayada:8080/bla -Method GETecho $RESPONSE

I'm getting following Response:

StatusCode        : 200StatusDescription : OKContent           : {123, 10, 108, 111...}RawContent        : HTTP/1.1 200 OK                    Content-Length: 21                    Date: Sat, 11 Jun 2016 10:11:03 GMT                    {                        flag:false                    }Headers           : {[Content-Length, 21], [Date, Sat, 11 Jun 2016 10:11:03 GMT]}RawContentLength  : 21

Content contains some wired numbers, so I went after RawContent, how would I parse the JSON inside, ignoring headers? or is there a clean way to get Content from those numbers?


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>