API GET request include "Notes" property?

Solved
tlrcmbs
Conversationalist

API GET request include "Notes" property?

Hi,

 

I'm relatively new to working with APIs, so maybe I'm missing something. However, I've scoured the API docs looking for a solution to my needs and cannot find one.

 

I'm currently writing a Python script to use within my organization that makes API calls to the Meraki Dashboard to query networks within a specified organization. Most of these networks that we have in the Meraki Dashboard have information under "Notes" (select the desired network and then navigate to Security Appliance > Appliance Status) that I would really like to be able to access through the API in order to retrieve helpful metadata through my script. 

 

Can this currently be done? 

 

Thanks

1 Accepted Solution
MerakiDave
Meraki Employee
Meraki Employee

Currently cannot retrieve the notes field, no.  But you can retrieve the tags, so perhaps a possible workaround is to leverage device tags as a form of notes.  Also make the wish, the API is being enhanced all the time, and I will mention this to the Solutions Architecture team as well.

 

View solution in original post

9 Replies 9
MerakiDave
Meraki Employee
Meraki Employee

Currently cannot retrieve the notes field, no.  But you can retrieve the tags, so perhaps a possible workaround is to leverage device tags as a form of notes.  Also make the wish, the API is being enhanced all the time, and I will mention this to the Solutions Architecture team as well.

 

tlrcmbs
Conversationalist

Thanks for the reply. I look forward to the future API updates.

MarkD_BT
Getting noticed

Hey tlrcmbs,

 

I'm unsure why meraki have giving you the wrong information but the area you refer to is shown via the api device list.

  Meraki Dashboard

'https://api.meraki.com/api/v0/networks/[networkId]/devices'

You will get added information of all devices against that network but exporting to a csv will allow you to filter again the MX devices and see the notes field.

 

I know the meraki documentation doesn't state that note is available but pulling that request will allow notes.

example of a call i do using this

wan1Ip""
wan2Ipnull
lanIp""
serial""
mac""
lat52.000000
lng-4.00000
address"Aberystwyth, Dyfed WALES"
notes"theres a note here"
tags" MX60 PCU SFBB-BTVPSTN-L1 "
name"MX60"
model"MX60"
networkId""
KJKUESTER
Conversationalist

Thanks.  I was just looking for a way to query the "notes" section.

DaveRey
Here to help

I'm actually looking for info about the "perPage" issue with

networks/{networkId}/devices

It will only return 1000 devices. There is supposed to be  a way to ask for more pages, but with an API we shouldn't have to.

 

I'm also looking to mass edit notes and the /devices endpoint won't list them all (I have over 2000 devices).

 

--edit--

 

So there is a "startingAfter" parameter that will accept a serial number as an identifier. You just have to give it the last serial number in the previous GET and it will carry on from there...

networks/{networkId}/devices?startingAfter=QABC-1234-5678

 

MarkD_BT
Getting noticed

Hey DaveRey, are these devices in one network or across multiple networks? If multiple networks you should build a array of all your devices in there. This can be exported to a csv or file for editing. I have a script that loops through each site in the org and pull back devices for each. I then use that to list of all devices in our org rather than the /organizations/{organizationId}/devices which has the startingAfter parameters.
DaveRey
Here to help

Hi, and thanks.  Yes, I've got several scripts where I pull all the networks, or the inventory depending on what I'm doing with the script.  I was writing a script to show all the notes and reset them if I choose.  Pulling from the /devices endpoint I only had to do 1 get (or so I thought).  I'm using perl::json so it's super easy to just check to see if there are less than 1000 elements in the array and if so, do another get with the last serial number pulled.

 

It was just a surprise to see that by default, the get /devices didn't pull everything, and it makes me wonder if any other endpoints are like that. Just something to be watchful for.

 

Cheers!

 

 

CBurkhead
Building a reputation

I have just gone through my own issues with the API and the 1000 items limitation. I was retrieving MX client information and security events. After attempting to get information from Meraki support on how to get the page information, I was able to find an answer on my own. This is Python specific, but I'd imagine that this information should be available for any language. I am using the requests library and by going through the information in the raw data returned from my GET, I found that headers['Link'] contains URLs for the GET that specify the startingAfter (and endingBefore) values that would be used for the "prev", "next", and "last" links for data on a webpage. I wrote a function that will get the token value from the "next" URL and then makes another GET request using that value for startingAfter and adding the new page data to my existing. It loops until there are no more "next" links and returns all of the concatenated data. Since the tokens used for various API endpoints could be serial numbers, timestamps, device IDs, etc., this allows me to get whatever Meraki is using for the token and pass it to my API calls, regardless of the data I am gathering.

 

Hope this helps others.

DaveRey
Here to help

Thanks for that! I'm using Perl with json module and cURL to get the data. So up until now I haven't been looking at the headers at all.   CURL -i  will show the headers and it does indeed have the link with the last tag. So I'll add that to the bag of tricks for any other pages that have the 1000 limit.  I've only come across it on the org/devices so far and I did notice that the last serial in the returned json array was the "marker" and if I asked for after that I got the next 1000.

 

Looking at the headers is something I didn't think of.

 

Cheers!

Get notified when there are additional replies to this discussion.