Invoke-Restmethod Outputting Strings

Welcome Forums General PowerShell Q&A Invoke-Restmethod Outputting Strings

This topic contains 1 reply, has 2 voices, and was last updated by

2 years, 3 months ago.

  • Author
  • #59182

    Points: 0
    Rank: Member

    I work for a Microsoft Partner and we are a Cloud Solution Provider. The CSP Program has a wonderful ReST API I would like to turn into a PowerShell module for my personal edification and to easy some of my daily tasks with deploying a ASP.NET website. The problem I have run into is when I call the API via Invoke-RestMethod I get a srtring that kind of looks like a JSON Object but I cant convert it from json. Belwo is my code for the Invoke-Restmethod. Can anyone see an issue with my code here?
    Headers match info found here = and the content type is "application/json;charset=utf-8". I tried UseBasicParsing and -UserAgent Parameter as well to no avail.

     Invoke-RestMethod -Method Get -Uri ' HTTP/1.1' -Headers $headers3 -ContentType $contentType  

    Output is here as a string:

  • #59305

    Points: 21
    Rank: Member

    I think you have tried the same things as I would have done.
    It looks like the response is somehow not really JSON because if it was JSON it would return a PSObject and not just string.
    Your response looks equal to the one on the MSDN page, what do you see when you only run

     Invoke-RestMethod -Method Get -Uri '

The topic ‘Invoke-Restmethod Outputting Strings’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort