Powershell Error using GET request: Cannot connect to remote server

Solved
BingleHopper
Conversationalist

Powershell Error using GET request: Cannot connect to remote server

This is based on the Postman documentation and some other stuff I saw online.  I am able to use the same API key and uri to perform a get through Postman. 

For automation reasons I would like to use Powershell.  This is a piece of a bigger script that generates a random password and makes an update using a PUT.  I have simplified it to what is seen below in the screenshot (including making it a GET) to make it easier to diagnose (hopefully).

 

api err.PNG

 

Also, if the uri has https, then do I need the tls1.2 line (line 3)?

 

Thanks.

1 Accepted Solution
Brash
Kind of a big deal
Kind of a big deal

Your syntax is right.
That should give you back an HTTP 200 along with some other data.

It definitely seems like the connection is getting blocked somewhere.

View solution in original post

8 Replies 8
PhilipDAth
Kind of a big deal
Kind of a big deal

This appears to be a fundamental issue, it is saying it is unable to connect to https://api.meraki.com/

 

Can I web browser on that machine connect?  When I try I get redirected to the Meraki dashboard login (so this should happen for you as well).

You don't have an internal proxy server or something you need to use to connect to the Internet?

Thanks for the response.

 

api.meraki.com redirects to the dashboard from a browser on the same machine. 

 

I don't believe there is a proxy.  The same operation can be done from Postman, but powershell gives the error shown prior. 

 

I also tried using nXXX.meraki.com through powershell (just to try other things) and it was unsuccessful as well (with the same error).

Are you able to make a request to google.com?  (aka, prove you can access something else on the Internet)

web err.PNG

 

Is this sufficient.  Maybe powershell is blocked by something?  Not sure if my syntax is even correct.

Brash
Kind of a big deal
Kind of a big deal

Your syntax is right.
That should give you back an HTTP 200 along with some other data.

It definitely seems like the connection is getting blocked somewhere.

Yeah, Powershell was blocked by CarbonBlack.

Thank you both for your help.

Brash
Kind of a big deal
Kind of a big deal

I personally haven't set the TLS version in my scripts.
Not sure whether that would cause a problem or not.

As @PhilipDAth mentioned - the error could be indicating a connection problem to the API backend.

 

For reference, this is a script that I use quite frequently without issue.
Meraki/Meraki Update Switchports.ps1 at main · Brash92/Meraki (github.com)

Get notified when there are additional replies to this discussion.