This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Using invoke-restmethod from a remote machine

I am trying to get invoke-restmethod working from a remote machine.

I started experimenting with a very simple command to return all the agents.

invoke-restmethod -uri 'https://[server ip]:8006/apprecovery/api/core/agents/' -method "Get" -Credential $cred

The credential is generated with Get-Credential and I have [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} to address the self-signed cert.

I am getting a generic error:

invoke-restmethod : The underlying connection was closed: An unexpected error occurred on a send.
At line:1 char:1
+ invoke-restmethod -uri 'https://[server ip]:8006/apprecovery/api/cor ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
   eption
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Any ideas where to go from here or were I may find more logs on the RR server?

It does load just fine from the same machine using a browser after the authentication prompt.

Parents
  • Tudor: Thank you for your reply. It helped!

    Especially thank you for suggested work around as it saved me the time it would have taken to find it which is great after all the time I spent on a bug that was never going to work.

    One change in the your suggested lines is to type the $agents variable as it returns a string otherwise.

    [xml]$agents = ($agentsquery.DownloadString("10.16.110.36:8006/.../agen
    ts/")).agents.agent
Reply
  • Tudor: Thank you for your reply. It helped!

    Especially thank you for suggested work around as it saved me the time it would have taken to find it which is great after all the time I spent on a bug that was never going to work.

    One change in the your suggested lines is to type the $agents variable as it returns a string otherwise.

    [xml]$agents = ($agentsquery.DownloadString("10.16.110.36:8006/.../agen
    ts/")).agents.agent
Children
No Data