Meraki API vlan profile creation

mvalerio31
Comes here often

Meraki API vlan profile creation

Hello ,

 

Has anyone seen an issue when creating vlan profiles using API ?

 

Im trying to add a new vlan profile into an existing network, here is what im trying :

 

post" https://api.meraki.com/api/v1/networks/:networkId/vlanProfiles"

 

{
"iname": "StandardVlan",
"name": "My Standard Vlan",
"isDefault": true,
"vlanNames": [
{
"name": "CORP",
"vlanId": "17"
},
{
"name": "AV",
"vlanId": "11"
},
{
"name": "MGMNT",
"vlanId": "10"
}
 
],
"vlanGroups": [
{
"name": "WW-TRUNK",
"vlanIds": "10,11,17"
}
]
}
 
when i try to push this i get the error below:
 
{
"errors": [
"invalid named VLANs: CORP,MGMNT. Please add them to the default profile first."
]
}
 
If I add these vlans to the default group im able to create the new profile using the API.
 
I'm confused why do i need to add the vlans first to the default group before creating a new vlan group with new vlans.
 
Thanks
9 Replies 9
alemabrahao
Kind of a big deal
Kind of a big deal

I think it's not a issue, it's just the order that you have to do the things.

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.
rhbirkelund
Kind of a big deal
Kind of a big deal

I think you need to remove ""isDefault": true," as this is not part of the request body.

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

I think @rhbirkelund has cracked it.  You could also try copying the code snippet in the documentation (on the right) and then start modifying it to be what you want.

https://developer.cisco.com/meraki/api-v1/create-network-vlan-profile/

 

PhilipDAth_0-1718093340796.png

 

mvalerio31
Comes here often

I tried this but still getting the same results 

mvalerio31
Comes here often

I just tried it still getting the same results 

mvalerio31
Comes here often

Screenshot 2024-06-11 at 9.46.09 AM.png

mvalerio31
Comes here often

Screenshot 2024-06-11 at 9.46.09 AM.png

rhbirkelund
Kind of a big deal
Kind of a big deal

I think what you need to do is to first add them to the default VLAN Profile. Afterwards you can create your own VLAN Profile "StandardVlan" with the VLANs.

That is.

  1. Update default VLAN Profile
  2. Create "StandardVlan".

 

 

 

#!/usr/bin/env python3

import meraki

def main():
    dashboard = meraki.DashboardAPI()

    network_id = "..."

    # Update Defalt
    iname = 'Default'
    name = 'Default Profile'
    vlan_names = [
        {
            'name': 'CORP', 
            'vlanId': '17'
        },
        {
            'name': 'AV', 
            'vlanId': '11'
        },
        {
            'name': 'MGMNT', 
            'vlanId': '10'
        }
    ]
    vlan_groups = [
        {
            'name': 'WW-TRUNK', 
            'vlanIds': '10,11,17'
        }
    ]
    response = dashboard.networks.updateNetworkVlanProfile(
        network_id, iname, name, vlan_names, vlan_groups
    )
    print(response)

    # Create custom VLAN Profile
    iname = 'StandardVlan'
    name = 'My Standard Vlan'
    vlan_names = [
        {
            'name': 'CORP', 
            'vlanId': '17'
        },
        {
            'name': 'AV', 
            'vlanId': '11'
        },
        {
            'name': 'MGMNT', 
            'vlanId': '10'
        }
    ]
    vlan_groups = [
        {
            'name': 'WW-TRUNK', 
            'vlanIds': '10,11,17'
        }
    ]
    response = dashboard.networks.createNetworkVlanProfile(
        network_id, name, vlan_names, vlan_groups, iname
    )

if __name__ == "__main__":
    main()

 

 

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.
mvalerio31
Comes here often

Thanks yeah if i add the vlans to the default profile it works, my question is why do i need to do this, makes no sense to me having to update a default profile in order to create mine but i assume thats how meraki works. 🙃

Get notified when there are additional replies to this discussion.