0

I am using a powershell script to get details from a website via invoke-webrequest. By using the credentials i have connecting to the website using invoke-restmethod to get the token. After getting the token i used the token to retrieve the details that i need by using invoke-webrequest. But then it is throwing the error this way.The URL is workingfine.

"Invoke-WebRequest : {"errors":[]}"

How can i get to know what is the problem with this request. API Query:

Invoke-WebRequest -Headers @{"X-Token" = "$token"} -Method Get -Uri "$URL"

error message:

Invoke-WebRequest : {"errors":[]} At C:\temp\RTPA\rtpa_vault3.ps1:24 char:24
+ ... ltdetails = Invoke-WebRequest -Headers @{"X-Token" = "$tok ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Theo
  • 57,719
  • 8
  • 24
  • 41
  • That can't be the entire error message.. Please edit your question and put whatever error you get **in full** in there – Theo Mar 14 '22 at 10:29
  • Please find the attached error message that i got @Theo – Developer____ Mar 14 '22 at 13:56
  • 1
    Does the code you mention to retrieve the token actually get the token you need, or is it surrounded by other stuff that does not belong to the token itself? Have you looked at what `$token` contains? (add a Write-Host $token) – Theo Mar 15 '22 at 11:15
  • Actually $token gives the correct token that i need and absolutely correct. By using that token i made a rest call to the website to retrieve the details i want. Then i am getting the error mentioned above. By using this token i am able to connect to the website. @Theo – Developer____ Mar 15 '22 at 15:09

0 Answers0