cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Motion Alert imageUrl Access Denied

SOLVED
Getting noticed

Motion Alert imageUrl Access Denied

Hi all, 

Working with the motion alert Webhook data.

 

The desired goal was to embed the snapshot image in an email notification 

 

 

$email_body .= '<img src="'. $webhook['alertData']['imageUrl'] .'" alt="Snapshot" width="500" height="281" /><br>';

 

 

 

Which worked. Once. So now I am sending both the URL and embedding the image. 

 

 

 

$email_body .= "Image URL: " . $webhook['alertData']['imageUrl'] . "<br>";
$email_body .= '<img src="'. $webhook['alertData']['imageUrl'] .'" alt="Snapshot" width="500" height="281" /><br>';

 

 

 

But when I click on the URL sent in the email, I am getting an error message. 

 

 

 

 

<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>OMITTED</RequestId>
<HostId>
BUNCHA STUFF
</HostId>
</Error>

 

 

 

Any thoughts? Is there somewhere I need to be storing a session ID or something? Or carrying over an ID?

 

Edit:

The access denied seems to only be happening when accessing the image from my MV71. The link seems to always work for my MV12 (the embed, not so much), but still testing this. 

 

~Andrew Afonso~

1 ACCEPTED SOLUTION

Accepted Solutions
Getting noticed

Re: Motion Alert imageUrl Access Denied

Well, found a workaround in the meantime. I can just take the timestamp from the MV71 alert, then generate a snapshot for it using the "snapshot" api, and embed that. 

View solution in original post

6 REPLIES 6
Kind of a big deal

Re: Motion Alert imageUrl Access Denied

You bring back bad memories.  I've spent a lot of time working with the MV API.

 

First make sure you are running V4 firmware.  Lots of bug fixes in this area.

 

Frequently the image is not available shortly after the request is generated.  So what I do is use a loop and try and request the image 30 or so times.  I use node.js.  I use up to a 30s delay between attempts, with a little bit of random backoff.  Something like:

 

setTimeout(processSnapshot,Math.random()*30000+1000,...,count+1)

 

Sometimes the image never becomes available, so I give up after the 30 attempts.

 

I take maybe 750 image retrievals a day.  It often works great for many days and then the error rate starts increasing.  

I run my cameras into an MS, and I use a port schedule to power cycle them once a week.  I find this improves the reliability a lot.  With the V3.x firmware I needed to do daily reboots.

 

Kind of a big deal

Re: Motion Alert imageUrl Access Denied

Another thought coming to me mind - do the first generation cameras support the image option of the webhook, or is this only a second generation camera feature?  Not sure.

 

I tried to find a reference to confirm all generations of camera support this but failed.  Perhaps try doing a search in this area.

Getting noticed

Re: Motion Alert imageUrl Access Denied

 

The first generation supports the alerts. Evidence seems to be indicating that the "access denied" page is only when I am trying to access a ImageURL from my MV71 alert, as opposed to my MV12. Maybe because dashboard doesn't offer "Motion Recap image"s for the 71? Seems a bit strange that I am even getting a URL, that does seem to be tied to an image file. But what can you do.

Kind of a big deal

Re: Motion Alert imageUrl Access Denied

>Maybe because dashboard doesn't offer "Motion Recap image"s for the 71?

 

That is what I meant.  I think the image option could be a feature of second generation cameras only.

 

Try to configure the dashboard to send you an email motion alert.  If the email doesn't have an image you definately wont be able to get it via API.

Getting noticed

Re: Motion Alert imageUrl Access Denied

Yep. Seems to all add up. Except for the fact that I am getting a 1 for "imageEnabled" on the MV71….

Getting noticed

Re: Motion Alert imageUrl Access Denied

Well, found a workaround in the meantime. I can just take the timestamp from the MV71 alert, then generate a snapshot for it using the "snapshot" api, and embed that. 

View solution in original post

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.