Postman - DHCP settings

sec1jrs
Here to help

Postman - DHCP settings

Hello everyone.  I'm starting new on Dashboard API.  Currently using Postman and the collections Meraki has.  Im having a little bit of issues with the DHCP and DHCP options when creating VLAN.  I can create VLAN with no issues.  But when I put Do not respond to DHCP Request, it defaults to Run a DHCP Server.  It really does not matter what option I put for dhcpHandling, it still defaults to Run a DHCP Server (see screen capture below).  It also does not put my dhcp options (for my other collection).  Any help is greatly appreciated.

 

 

sec1jrs_0-1586288622663.png

 

5 Replies 5
MerakiDave
Meraki Employee
Meraki Employee

Hi @sec1jrs I sometimes say "pictures or it didn't happen" but you attached a screen shot!  Anyway, I just tried this and it worked fine using my own Postman on my own home lab environment. 

 

Make sure you are using this call: 

https://n7.meraki.com/Meraki-San-Franc/n/Ykbfgdh/manage/support/api_docs/v0#update-a-vlan

 

Your call in Postman looks like it is the "List the VLANs" but should be the "Update" call, which includes a VLAN id # in the call.  Such as PUT /networks/{{networkId}}/vlans/{{vlanId}} so the VLAN id: value of 100 is in the PUT command itself, not in the body.

 

You should be able to use PUT {{baseUrl}}/networks/{{networkid}}/vlans/100

and then the body could simply consist of:

{
"dhcpHandling": "Do not respond to DHCP requests"
}

 

Then run the GET {{baseUrl}}/networks/{{networkid}}/vlans to confirm you see the change.

 

And of course, you should probably use a {{my_vlanId}} variable for the VLAN versus hard-coding it to 100.

Hope that helps!

 

@MerakiDave  - Thank you for your reply.  I was actually doing a POST since I need to add VLANS.  But I just tested the PUT on my created VLAN and it worked!   If I have to do 1 collections (with 2 rules), that's fine POST/PUT.  The end result is the same.  Thanks again for your assistance.

Edgar-VO
Building a reputation

Hi...

 

I had some issues as well in changing the dhcp option using python, but now it is working..

 

As an example i have the function i have created including the API call. It is one of my first function so a bit messy...

Hmmmmm maybe rewrite it with my current knowledge of Meraki API programming

 

 

Anyway.... check it out.... Postman is nice to check things, but create your own organisation and add some devices to it for testing purposes.. Makes life much easier

 

This example changes DNS names, Creates Reservations, and changes some dhcpoptions

 

def Update_Site_VLAN_Project(def_network,def_vlan_id,def_subnet😞

    #
    # Update the network using the old info
    #

    param = dashboard.vlans.getNetworkVlan(network_id,def_vlan_id)

    my_reservation = ""
    my_lijst = []
    del param['id']
    del param['networkId']

    #
    # Change the default DNS nameservers
    # Creating reservations for VLAN 500 and 600
    #

    if def_vlan_id == "500" or def_vlan_id == "600":
        param['dnsNameservers'] = '10.24.16.151\n10.24.16.152'
        
        ip_start_1 = calc_ip_OT_Supplier(def_subnet,"0","1")
        ip_end_1 = calc_ip_OT_Supplier(def_subnet,"0","99")
        ip_start_2 = calc_ip_OT_Supplier(def_subnet,"0","200")
        ip_end_2 = calc_ip_OT_Supplier(def_subnet,"0","254")
        
        my_reservation = eval("{'start': '"+ip_start_1+"', 'end': '"+ip_end_1+"', 'comment': 'IT Reserved'}")
        my_lijst.append(my_reservation)

        my_reservation = eval("{'start': '"+ip_start_2+"', 'end': '"+ip_end_2+"', 'comment': 'IT Reserved'}")
        my_lijst.append(my_reservation)

        param['reservedIpRanges'] = my_lijst

    if def_vlan_id == "500":
        my_lijst = []
        my_lijst.append(eval("{'type': 'text', 'code': '15', 'value': 'company.org'}"))
        param['dhcpOptions'] = my_lijst

    #
    # Adding the DHCP Options for VoIP
    #

    if def_vlan_id == "600":
        my_lijst = []
        my_lijst.append(eval("{'type': 'text', 'code': '150', 'value': '10.24.75.11,10.9.8.11'}"))
        param['dhcpOptions'] = my_lijst


    if def_vlan_id == "1":

        #
        # Adding reservation .21 to .254
        

        ip_start_1 = calc_ip_OT_Supplier(def_subnet,"0","21")
        ip_end_1 = calc_ip_OT_Supplier(def_subnet,"0","254")

        my_reservation = eval("{'start': '"+ip_start_1+"', 'end': '"+ip_end_1+"', 'comment': 'IT Reserved'}")
        my_lijst.append(my_reservation)

        param['reservedIpRanges'] = my_lijst

        #
        # Changing subnet to routable subnet
        #

        my_mx_subnet = def_subnet +"/24"
        param['subnet'] = my_mx_subnet
        
        def_subnet = calc_ip_OT_Supplier(def_subnet,"0","254")
        param['applianceIp'] = def_subnet

    response = dashboard.vlans.updateNetworkVlan(network_id,def_vlan_id,**param)

 

 

@Edgar-VO - Thanks for the reply.  I'm just a beginner in API and took the Postman route.  So I have not learn Python yet.  This will come in handy once I start using Python.

Edgar-VO
Building a reputation

Just try..... It is so much more powerful than Postman (which is great for sending a few API calls). Python is very easy to learn, and you have so much examples on the net.... And of course members of this forum which are highly motivated and skilled

 

Get notified when there are additional replies to this discussion.
Welcome to the Meraki Community!
To start contributing, simply sign in with your Cisco account. If you don't yet have a Cisco account, you can sign up.