cancel
Showing results for 
Search instead for 
Did you mean: 

MV Snapshot API returns an error sometimes

SOLVED
Highlighted
Conversationalist

MV Snapshot API returns an error sometimes

Hi , all

 

I develop an application with MV Snapshot API (C#.net).
Before this , I tried to use Snapshot API with curl and Postman.
The command sends and returns are OK from above both tools.


and the command is successful from my application as well as both tools.
but , from my application , sometimes Snapshot API returns an error with the same source codes,not always.

the error message is 
"You are being
<a href="https://n25.meraki.com/api/v0/networks/L_xXXXXXXXXXXXXXXXXXX/cameras/YYYY-YYYY-YYYY/snapshot">redire...>"

Is this a bug of the API? or should I change my codes? 

I use RestClient. the following is the part of my codes,

public static string GetSnapshot() // Get a snapshot from MV camera
{

var client = new RestClient("https://api.meraki.com/api/v0/networks/L_XXXXXXXXXXXX/cameras/" + MVSerialNumber + "/snapshot");

var request = new RestRequest(Method.POST);

request.AddHeader("X-Cisco-Meraki-API-Key", MyMerakiAPIKey);
IRestResponse response = client.Execute(request);

return response.Content;
}

 

Any help would be appreciated.

Regards

1 ACCEPTED SOLUTION

Accepted Solutions
Kind of a big deal

Re: MV Snapshot API returns an error sometimes

Hmm that's not a very helpful error but I think it may have to do with the redirection to your specific shard.

 

Try using the shard url directly in your API call.

 

Replace:

var client = new RestClient("https://api.meraki.com/api/v0/networks/L_XXXXXXXXXXXX/cameras/" + MVSerialNumber + "/snapshot");

by:

var client = new RestClient("https://n25.meraki.com/api/v0/networks/L_XXXXXXXXXXXX/cameras/" + MVSerialNumber + "/snapshot");
3 REPLIES 3
Kind of a big deal

Re: MV Snapshot API returns an error sometimes

Hmm that's not a very helpful error but I think it may have to do with the redirection to your specific shard.

 

Try using the shard url directly in your API call.

 

Replace:

var client = new RestClient("https://api.meraki.com/api/v0/networks/L_XXXXXXXXXXXX/cameras/" + MVSerialNumber + "/snapshot");

by:

var client = new RestClient("https://n25.meraki.com/api/v0/networks/L_XXXXXXXXXXXX/cameras/" + MVSerialNumber + "/snapshot");
Conversationalist

Re: MV Snapshot API returns an error sometimes

Hi

 

The error is gone away after replacing the url.

you're great!!

 

Thank you so much!!!

Kind of a big deal

Re: MV Snapshot API returns an error sometimes

You're welcome! Note that the shard might be different in other organizations so to create a more robust script you should make it follow the redirect or figure out the shard number by performing a GET on your org first.

 

"Note also that most HTTP libraries and clients will not follow a redirect with an HTTP verb other than GET, and may instead follow the redirect but substitute GET for the HTTP verb. As a result, you may find a redirect on DELETE, POST, or PUT will look as though a GET was requested. To avoid this, first perform a GET on the organization you are working with, and store the URL you are working with, then use that URL for subsequent requests (particularly those that modify state)."

Source:

https://documentation.meraki.com/zGeneral_Administration/Other_Topics/The_Cisco_Meraki_Dashboard_API

Welcome to the Meraki Community!
To start contributing, simply sign in with your Cisco account. If you don't yet have a Cisco account, you can sign up.