cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
5489
Views
8
Helpful
9
Replies

Find Network Client

Ed Roche
Level 4
Level 4

Hi All

I am testing out the Get Network Client option under networks - monitor - clients.

The only I can get this to work is if I search ID value which looks to be a system id. I tried IP (I have Track by IP selected), tried MAC address, and Description but all come back with Not Found error. Below is what I have which was cut and paste right from the API page.

import meraki

API_KEY = '<my API>'

dashboard = meraki.DashboardAPI(API_KEY)

network_id = '<my id>'

client_id = '10.204.14.95'

response = dashboard.networks.getNetworkClient(

    network_id, client_id

)

print(response)

Here is the output I get

2024-07-29 14:18:31 meraki: INFO > Meraki dashboard API session initialized with these parameters: {'version': '1.46.0', 'api_key': '************************************55b7', 'base_url': 'https://api.meraki.com/api/v1', 'single_request_timeout': 60, 'certificate_path': '', 'requests_proxy': '', 'wait_on_rate_limit': True, 'nginx_429_retry_wait_time': 60, 'action_batch_retry_wait_time': 60, 'network_delete_retry_wait_time': 240, 'retry_4xx_error': False, 'retry_4xx_error_wait_time': 60, 'maximum_retries': 2, 'simulate': False, 'be_geo_id': None, 'caller': None, 'use_iterator_for_get_pages': False}
2024-07-29 14:18:31 meraki: INFO > GET https://api.meraki.com/api/v1/networks/N_755478837491402474/clients/10.204.14.95
2024-07-29 14:18:32 meraki: ERROR > networks, getNetworkClient - 404 Not Found, b'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtm'
Traceback (most recent call last):
File "/mnt/m2ssd/python/client_find_test.py", line 16, in <module>
response = dashboard.networks.getNetworkClient(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/meraki/api/networks.py", line 473, in getNetworkClient
return self._session.get(metadata, resource)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/meraki/rest_session.py", line 306, in get
response = self.request(metadata, 'GET', url, params=params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/meraki/rest_session.py", line 300, in request
raise APIError(metadata, response)
meraki.exceptions.APIError: networks, getNetworkClient - 404 Not Found, <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtmplease wait a minute if the key or org was just newly created.

Any thoughts?

Thanks in Advance!

1 Accepted Solution

Accepted Solutions

Raphael_L
Meraki Community All-Star
Meraki Community All-Star

If you are trying to find a client via it's MAC , you should use this endpoint : https://developer.cisco.com/meraki/api-v1/get-organization-clients-search/

client_id is an ID used to identify a client. If you don't know the ID , you can't use getNetworkClient. You would have to use getNetworkClients to get a list of clients from that network.

View solution in original post

9 Replies 9

Raphael_L
Meraki Community All-Star
Meraki Community All-Star

If you are trying to find a client via it's MAC , you should use this endpoint : https://developer.cisco.com/meraki/api-v1/get-organization-clients-search/

client_id is an ID used to identify a client. If you don't know the ID , you can't use getNetworkClient. You would have to use getNetworkClients to get a list of clients from that network.

Ed Roche
Level 4
Level 4

Hi @Raphletourn

Thanks for the response, the page for Get Network Client says we can search on MAC, IP or Client Key. Is that a miss print?

image.jpeg

Raphael_L
Meraki Community All-Star
Meraki Community All-Star

Ummmm ! I'm not sure , I would have to test after my vacations. Maybe our friend @jscorb knows the answer for that one.

It doesn't say you can search by MAC or IP.

What I see here...

https://developer.cisco.com/meraki/api-v1/get-network-client/

Is "Return the client associated with the given identifier. Clients can be identified by a client key or either the MAC or IP depending on whether the network uses Track-by-IP.".

You must give the client key as a mandatory argument, you cannot give MAC or IP. I think the rest could be worded better.

Edit: re-reading, I think it reads ambiguously. I'm also on holiday now, so not really set up for testing, plus it's beer time 🙂 I suggest do a search for the MAC of a current client you know to be active and if it isn't found, open a support case and ask.

As @Raphletourn says, if you want to search by MAC, use the other call, though MAC randomisation may mean some device families are not reliably identifiable this way.

image.jpegYeah that works but the one reason I would this is to find were a certain device is plugged into a switch. I don't see that info in the output though.

*Edit

I found the field but it comes back as None.

Raphael_L
Meraki Community All-Star
Meraki Community All-Star

Looking at the output , this is expected since MX do not have "real" switchports 😞

That's true, our branches don't have Meraki switches yet but it does work when searching a MAC that is plugged into a Meraki switch. DUH🙄

Jamiegprice15
Level 4
Level 4

So a bit of a bend on this one because I like using APIs... but just hooked up our Meraki to SolarWinds- it's looking pretty handy to look up mac addresses.

@Jamiegprice15 yeah unfortunately our branch offices have their routing done on the MX there so since MX don’t provide ARP info in SNMP we can’t get the full info for the desktop users at those locations. For our HQ users we can get that info but would love to just be able to have all out admin tasks in one big script. This will keep our desktop support and help desk out of some stuff they really don’t need access to.