API to add network to a device.

BretO
New here

API to add network to a device.

I'm working on some automation scripting and have figured out most of what I need except I can't figure out how to connect a network to a device.  I have a script to get the details of an existing device and it shows a "networkId": "L_XXXXXXXXXXXXXX".

 

"networkID" is not listed in the schema on Update Device - Meraki Dashboard API v1 - Cisco Meraki Developer Hub so is this possible to do or is there another API call I should be using instead?

 

If I try to update a device with a PUT and using a "networkId": "L_YYYYYYYYYYYYY" I get

 

Status Code: 400
Response Text: {"errors":["Error for /devices/{serial}: None of the fields ('name', 'tags', 'lat', 'lng', 'address', 'notes', 'moveMapMarker', 'switchProfileId' or 'floorPlanId') were specified."]}

5 Replies 5
David_Jirku
Meraki Employee
Meraki Employee

You will have to remove it from the existing network https://developer.cisco.com/meraki/api-v1/remove-network-devices/ back into inventory and then assign it to the new network using https://developer.cisco.com/meraki/api-v1/claim-network-devices/

 

BretO
New here

The network and device I'm testing with are not part joined to any other device/network yet.  In the example above I am able to see the 'networkId' if I look at an existing device that is already setup. 

 

In the link you posted that shows 'networkId' as required but does not show that field in any of the examples or Schema Definition.  That page looks the same as Claim Into Organization Inventory - Meraki Dashboard API v1 - Cisco Meraki Developer Hub to Claim a device into the inventory. I already have it in my inventory I just need to link it with a network. 

BretO
New here

Oh I just spotted the 'networkId' as part of the API path.  Let me test that.

 

David_Jirku
Meraki Employee
Meraki Employee

bingo 😉 glad it worked! That construct of the API path being part of the context for the action is consistent in the API

BretO
New here

That worked.   Thanks

 

The title 'Claim Network Devices' sounds way too similar to the other document of trying to claim it into the Inventory. 

Get notified when there are additional replies to this discussion.