Invoke-WebRequest -Method POST

Welcome Forums General PowerShell Q&A Invoke-WebRequest -Method POST

Viewing 1 reply thread
  • Author
    Posts
    • #225468
      Participant
      Topics: 4
      Replies: 6
      Points: 59
      Rank: Member

      Hi,

      I have a project to run a cmdlet whether on a server or workstation to get the list of updates which includes the description of the update, date/time installed, so I went ahead and used Get-WUHistory and it did showed me the results I wanted.

      Here’s my issue, my boss wanted me to send/export the results instead of saving it to a file, he wants me to send the results to one of our websites. I used the cmdlet

      Invoke-WebRequest -Uri https://<domain&gt; -Method POST

      But I talked to one of the developer of the website and told me to include the ff:

      token: xxxxxxxxxx

      private_ip: 192.x.x.x

      I run the following cmdlet below:

      Get-WUHistory

      Invoke-WebRequest -Uri https://<domain&gt; -Method POST

      And I’m getting a Bad Request (400) error so I’m not sure if I’m doing the proper way in doing POST

      Thanks

      TECH-JEFF

      • This topic was modified 3 weeks, 1 day ago by TECH-JEFF65.
      • This topic was modified 3 weeks ago by TECH-JEFF65.
    • #225546
      Participant
      Topics: 0
      Replies: 11
      Points: 157
      Helping Hand
      Rank: Participant

      Hello Jeff,

      Looks like you need to get more information from your API developer and use tools like Postman or any addons for your browser to debug/test your API requests. For example Resting for Mozilla:

      https://addons.mozilla.org/en-US/firefox/addon/resting/

      From your post it appears that you need to provide auth token to your API(in headers or in query) and POST your Get-WUHistory output int the request body.

      Hope that helps.

       

Viewing 1 reply thread
  • You must be logged in to reply to this topic.