api.meraki.com returns 404, shard returns 200

Adam2104
Building a reputation

api.meraki.com returns 404, shard returns 200

I'm just starting to play around with the API. My user has full access to the org and also the network I'm playing with. I'm just tinkering for now making API requests via curl on the command line of my Mac. If I make the request against "api.meraki.com" I get a 404 and no data is returned. If I change it to the shard I'm on "n###.meraki.com" I get a 200 OK and the data I'm expecting. So, from this I assume my API key is valid. Why doesn't the request work on api.meraki.com, but does when I point it at the specific shard?

 

Works:

 

curl -X GET \
--url 'https://n456.meraki.com/api/v0/organizations' \
-H 'X-Cisco-Meraki-API-Key: foo'\
-H 'Accept: application/json'

 

 

Doesn't work:

 

curl -v -X GET \
--url 'https://api.meraki.com/api/v0/organizations' \
-H 'X-Cisco-Meraki-API-Key: foo'\
-H 'Accept: application/json'

 

 

5 Replies 5
PhilipDAth
Kind of a big deal
Kind of a big deal

You need to tell curl to follow redirects.  I think the options is -L.

Adam2104
Building a reputation

I'd agree, if the server was sending a 302 back, but it isn't, it's sending a 404.

PhilipDAth
Kind of a big deal
Kind of a big deal

There may be a subsequent issue - but let's start by resolving those things that are 100% wrong.  When you call api.meraki.com it will authenticate and redirect you to the correct shard.

So if you don't follow the redirects you are guaranteed that part of that process will fail.

 

Also take a look at the curl examples in the API documentation.

https://dashboard.meraki.com/api_docs/v0#list-the-organizations-that-the-user-has-privileges-on

Also note that some OSs are finicking about whether you use single or double quote.

Greenberet
Head in the Cloud

Delete the api key and generate a new one. After that wait a few minutes before you are testing it out.

I had this issue once too and I've opened a case for this.

The support technician told me, that there was a problem with the replication of the api key. With deleting/generate the replication will be triggered again.

The new key was working fine then.

Adam2104
Building a reputation

This started working with both api keys late yesterday. I haven't changed anything on my end, it simply started working. I'm not sure what changed but it's good to go now.

Get notified when there are additional replies to this discussion.