- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
redirects from api.meraki.com sockets
Hi team.
Bit of an odd question. Using sockets to send my GET's, and if I send it directly to https://api.meraki.com it redirects to n151.meraki.com.
All well and good, I just followed the redirect and used that GET as my reference.
My question is if the API's all go through n151, or if I will really need to parse that initial response to the reply from https://api.meraki.com for the correct node. This is intended for anyone to be able to use, not just myself.
Solved! Go to solution.
- Labels:
-
Dashboard API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Each org has a shard it's on, right? api.meraki.com attempts to identify the shard for your organization, then redirects to the correct shard. In this case, n151.
If you want to know the shard for a specific organization, you can use Get Organizations and then trim the org['url'] kinda like this. I'm using Python. Try running this in a Python shell.
Then you can just pass that to your request statement instead of api.meraki.com. Can speed things up a little...
org = {"id": "random", "name": "Test", "url": "https://n263.meraki.com/gibberish"}
print(f"Original URL: {org['url']}")
urlLength = org['url'].find('com') + 3
orgShard = org['url'][8:urlLength]
print(f"Trimmed shard URL: {orgShard}")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Each org has a shard it's on, right? api.meraki.com attempts to identify the shard for your organization, then redirects to the correct shard. In this case, n151.
If you want to know the shard for a specific organization, you can use Get Organizations and then trim the org['url'] kinda like this. I'm using Python. Try running this in a Python shell.
Then you can just pass that to your request statement instead of api.meraki.com. Can speed things up a little...
org = {"id": "random", "name": "Test", "url": "https://n263.meraki.com/gibberish"}
print(f"Original URL: {org['url']}")
urlLength = org['url'].find('com') + 3
orgShard = org['url'][8:urlLength]
print(f"Trimmed shard URL: {orgShard}")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nash,
So if I send this
GET /api/v0/networks/NETWORKNUM/clients HTTP/1.1
Host: api.meraki.com
Accept: application/json
x-cisco-meraki-api-key: keyhere
Content-Length: 15
timespan=1800
to https://api.meraki.com, I get back
<html><body>You are being <a href="https://n151.meraki.com/api/v0/networks/NETWORKNUM/clients">redirected</a>.</body></html>
Just wanted to confirm that it changes based on the customers shard, which is sounds like is the case, and wasn't just n151 for all API stuff. Thanks for the clarification!
~Andrew Afonso~
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Strongly recommend you scrub that network number that you've included. That's why my example just said gibberish. 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oof. Thought about that, but I thought the only confidential part was the API key. How dangerous is publishing the network num (Just want to know if I need to go searching if I've done it anywhere else).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To me it's all keys. Keys should be private, even if you need multiple keys in order to complete a transaction.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is a great example of why I have been promoting the use of dotenv, and for the complete removal of API keys and sensitive information from code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is a new beta API service called "Mega Proxy" that does not use redirects. You can try it out using api-mp.meraki.com instead of api.meraki.com.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Lololol. Literally just finished & published the project I was asking for. But I may add that in. Can anyone just use the api-mp?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>Can anyone just use the api-mp?
Yes.
