getDevice and updateDevice doesn't work

churches_co
Just browsing

getDevice and updateDevice doesn't work

I'm making a simple web-application for a client using the Meraki API. But neither of the two requests that is needed for the application is working and I cannot seem to get what is wrong. It's regarding the get-request getDevice and put-request updateDevice. All I receive is 404.

 

This is for the get-request:

curl -L --request GET \

--url https://api.meraki.com/api/v1/devices/XXXXXXXXXXXX \

--header 'Content-Type: application/json' \

--header 'Accept: application/json' \

--header 'X-Cisco-Meraki-API-Key: [my api key]'

 

and this is for the put-request:

 

curl -L --request PUT \

--url https://api.meraki.com/api/v1/devices/XXXXXXXXXXXX \

--header 'Content-Type: application/json' \

--header 'Accept: application/json' \

--header 'X-Cisco-Meraki-API-Key: [my api key]'

 

(i'm usually doing all of this in postman in then I have a body of course for the put-request)

 

i've also tried tried adding networks/network_id along with /sm in the path, but nothing is working and the documentation doesn't provide any answer whatsoever. And yes my key is valid, i can still get all the devices from a certain network and such. And I've made sure that the device is not in the inventory but in an actual network. Any ideas or has anyone had the same problem?

6 Replies 6
alemabrahao
Kind of a big deal
Kind of a big deal

First, ensure you have the right network permission(which I assume you already have as you can get the organization list). Then try the below curl command to rule out any library issues.

 

curl -L --request GET \
--url https://api.meraki.com/api/v1/devices/[YOUR SERIAL NUMBER] \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'X-Cisco-Meraki-API-Key: [YOUR API KEY]'

I am not a Cisco Meraki employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.

Please, if this post was useful, leave your kudos and mark it as solved.
churches_co
Just browsing

I may be wrong, but what you wrote is identical to mine. Is it working for you that request?

alemabrahao
Kind of a big deal
Kind of a big deal

Yes, the commands you are running are correct. Just check if you have the correct network permission, if the S/N and API key are correct.

If everything is ok, I suggest you open a support case.

I am not a Cisco Meraki employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.

Please, if this post was useful, leave your kudos and mark it as solved.
churches_co
Just browsing

Yeah I opened a case, thanks for the help!

rhbirkelund
Kind of a big deal
Kind of a big deal

Try updating your curl command to use the Bearer authorization instead.

curl -L --request GET \
--url https://api.meraki.com/api/v1/devices/{serial} \
--header 'Authorization: Bearer 75dd5334bef4d2bc96f26138c163c0a3fa0b5ca6' \
--header 'Accept: application/json'

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

 

LinkedIn ::: https://blog.rhbirkelund.dk/

Like what you see? - Give a Kudo ## Did it answer your question? - Mark it as a Solution 🙂

All code examples are provided as is. Responsibility for Code execution lies solely your own.
PhilipDAth
Kind of a big deal
Kind of a big deal

On the page @rhbirkelund gave (or any other API page), select "Code Snippets", "Curl" to get a copy and paste example.

 

PhilipDAth_0-1720428761419.png

 

Get notified when there are additional replies to this discussion.