MV Snapshot API returns an error sometimes

Solved
Takuma
Here to help

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
BrechtSchamp
Kind of a big deal

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");

View solution in original post

3 Replies 3
BrechtSchamp
Kind of a big deal

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");
Takuma
Here to help

Hi

 

The error is gone away after replacing the url.

you're great!!

 

Thank you so much!!!

BrechtSchamp
Kind of a big deal

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

Get notified when there are additional replies to this discussion.