Hi,
I'm trying to take a snapshot by using the CURL giving the network id, the camera's serial number, and all the necessary data. However, when making the POST of the CURL, I get a 400 error Response.
HTTP ERROR 400
Problem accessing /cameras/live_snapshot. Reason:
can't parse j son parameters: No content to map due to end-of-input
I'm not sure what the problem is exactly.
Thank You,
Can you post the curl command you're using? Be sure to redact your API key, serial and network ID.
Hi,
I'm using Python requests:
headers = {
'X-Cisco-Meraki-API-Key': API_KEY,
'Content-Type': 'application/json',
}
response = requests.post('https://api.meraki.com/api/v0/networks/'+NET_ID+'/cameras/'+SERIAL_CAM1+'/snapshot', headers=headers)
It looks like the API doc is wrong. remove the content-type json stuff and it works for me.
headers = { 'X-Cisco-Meraki-API-Key': API_KEY, } requests.post('https://api.meraki.com/api/v0/networks/<netID>/cameras/<serial>/snapshot', headers=headers)
Or
curl -L -H 'X-Cisco-Meraki-API-Key: <api_key>' -X POST 'https://api.meraki.com/api/v0/networks/<Net_ID>/cameras/<serial>/snapshot'
Thank you very much, now it works correctly 😄
Hey @TonyC @CameronMoody FYI looks like the API doc for Camera snapshots might have an error in it.
Sorry if this isn't you guys, but I thought the API guy and the doc guy would be good places to start 🙂
Hello @TonyC I am trying to fetch the snapshot through code, but there is no possible way, it only works in a browser... Do you have any example?
I used Python:
import requests import json API_KEY = 'YOUR_API_KEY' NET_ID = 'YOUR_NETWORK_ID' SERIAL_CAM = 'YOUR_CAMERA_SERIAL_NUMBER' headers = { 'X-Cisco-Meraki-API-Key': API_KEY, } try: response = requests.post('https://api.meraki.com/api/v0/networks/'+NET_ID+'/cameras/'+SERIAL_CAM+'/snapshot', headers=headers) except requests.exceptions.RequestException as e: print("Error: %s" %(e)) data = response.json() url_link = data['url'] print(url_link)
I did it with node , the problem as described here https://community.meraki.com/t5/Solutions-APIs/Snapshot-API-not-working-404/td-p/45294 is that i did need to wait 5 seconds before fetching
+1 for this. I have been trying without success with php curl. I have the link url, but cannot retrieve the actual image.
After you have the link, request the link.
try:
response = requests.request("POST", urlApi, headers=header, data=payload)
except:
print ('error')
print (response.status_code)
if response.status_code == 202:
urlVideo = response.text
time.sleep(5) # wait 5 sec then the image is availble
dc_data = eval(response.text)
urlVideo = (dc_data['url'])
resp = requests.request("GET", urlVideo, stream=True)
fn = 'imagename.jpg'
try:
with open(fn, 'wb') as f:
for chunk in resp:
f.write(chunk)
f.close()