get_network_clients giving 'HTTP response not OK' error

SOLVED
RobJ
New here

get_network_clients giving 'HTTP response not OK' error

I'm pretty new to using Python, and I'm having issues getting this to work. I set the collect dict like this

collect['network_id'] = netids['deepellum']
collect['t_0'] = 't0'
collect['timespan'] = 900
collect['per_page'] = 500
collect['starting_after'] = 'startingAfter'
collect['ending_before'] = 'endingBefore'

 and then I have this

result = clients_controller.get_network_clients(collect)

As you can see, I pretty much just copied from the meraki sdk documentation.

 

If I take all the optional params out and just leave the network ID inside collect it runs with no errors. I'm sure there must be something simple I am missing, I'm just new to Python and API's in general. Any help would be much appreciated.

1 ACCEPTED SOLUTION
nealgs
Building a reputation

with regards to the Meraki API - have you installed PostMan?

 

I'm pretty new to the meraki api and have be messing with powershell rather than python and found that Postman with the Meraki Dashboard API collection installed helps you to run various api calls without the need for all the convoluted script code around it.

 

once you've sorted out the parameters etc for the particular API call, you can then wrap the necessary code around it etc.

 

With regards to your code - if you run the api call in Postman, it fails with the values you have below with a bad request error or 404 error.

 

The t0 parameter needs to be a valid time value - if you remove it as a parameter, like so and do this in Postman it returns a list of clients

 

https://xxx.meraki.com/api/v0/organizations/<orgid>/networks/<networkID>/clients?&timespan=900&perPa...

 

try the your code in python again, but remove the t0 line and just have either startingafter = "" or endingBefore = "" (aparently can't have both according to error returned by Postman if both included in the API call

 

e.g. - this fails:

 

https://xxx.meraki.com/api/v0/organizations/<orgid>/networks/<networkID>/clients?&timespan=900&perPa...""

 

let me know how you get on

 

 

View solution in original post

5 REPLIES 5
nealgs
Building a reputation

with regards to the Meraki API - have you installed PostMan?

 

I'm pretty new to the meraki api and have be messing with powershell rather than python and found that Postman with the Meraki Dashboard API collection installed helps you to run various api calls without the need for all the convoluted script code around it.

 

once you've sorted out the parameters etc for the particular API call, you can then wrap the necessary code around it etc.

 

With regards to your code - if you run the api call in Postman, it fails with the values you have below with a bad request error or 404 error.

 

The t0 parameter needs to be a valid time value - if you remove it as a parameter, like so and do this in Postman it returns a list of clients

 

https://xxx.meraki.com/api/v0/organizations/<orgid>/networks/<networkID>/clients?&timespan=900&perPa...

 

try the your code in python again, but remove the t0 line and just have either startingafter = "" or endingBefore = "" (aparently can't have both according to error returned by Postman if both included in the API call

 

e.g. - this fails:

 

https://xxx.meraki.com/api/v0/organizations/<orgid>/networks/<networkID>/clients?&timespan=900&perPa...""

 

let me know how you get on

 

 

Yeah, that worked perfectly. Thanks so much!

nealgs
Building a reputation

great stuff RobJ - good to hear 🙂

 

Not sure why my post appears twice though - anyone help on how to post properly in a forum - lol 🙂

MeredithW
Meraki Alumni (Retired)
Meraki Alumni (Retired)

Your post is both an accepted solution AND a regular old post, so it gets to appear twice 😛
Meredith W | Community Manager, Cisco Meraki


Found this helpful? Give me some Kudos! (click on the little up-arrow below) New to the community? Get started here
nealgs
Building a reputation

aha!, thanks MeredithW - thought it was old age creeping in 😄

Get notified when there are additional replies to this discussion.