<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: stickyMacAllowList error must be an array in Network Platform API</title>
    <link>https://community.cisco.com/t5/network-platform-api/stickymacallowlist-error-must-be-an-array/m-p/5444159#M6870</link>
    <description>&lt;P&gt;Should this line:&lt;/P&gt;&lt;PRE class="lia-code-sample language-python"&gt;&lt;CODE&gt;mac_allowed = input ('MAC Address [xx:xx:xx:xx:xx:xx, xx:xx:xx:xx:xx:xx): ')&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;be?&lt;/P&gt;&lt;PRE class="lia-code-sample language-python"&gt;&lt;CODE&gt;mac_allowed = input ('MAC Address [xx:xx:xx:xx:xx:xx, xx:xx:xx:xx:xx:xx]: ')&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 20 Aug 2024 10:30:36 GMT</pubDate>
    <dc:creator>Philip D'Ath</dc:creator>
    <dc:date>2024-08-20T10:30:36Z</dc:date>
    <item>
      <title>stickyMacAllowList error must be an array</title>
      <link>https://community.cisco.com/t5/network-platform-api/stickymacallowlist-error-must-be-an-array/m-p/5444157#M6868</link>
      <description>&lt;P&gt;Having an issue with trying to update the stickyMacAllowList value. Doesn't matter if I leave it blank to try and remove the current mac address or if I add a valid mac (xx:xx:xx:xx:xx:xx) I keep getting the following error:&lt;/P&gt;&lt;P&gt;400 Bad Request, {'errors': ["'stickyMacAllowList' must be an array"]}&lt;/P&gt;&lt;P&gt;Below is my full code. Thanks in advance.&lt;/P&gt;&lt;PRE class="lia-code-sample language-python"&gt;&lt;CODE&gt;import meraki

import os

import time

import pprint

from colorama import init as colorama_init

from colorama import Fore, Back

from colorama import Style

import inquirer

from inquirer.themes import GreenPassion

import progressbar



def get_meraki_api_key():

    api_key = os.getenv('MERAKI_API_KEY')

    if not api_key:

        raise ValueError("No API key found. Please set the MERAKI_API_KEY enviroment variable.")

    return api_key







# Select Device    

sw_sn = 'my sn'

port = input ('\n' + 'What port would you like to update? (1,2...48): ')

print (Fore.BLUE,Style.BRIGHT +'\n' + 'Below is the current information for that port:  ' + '\n')

API_KEY = get_meraki_api_key()

dashboard = meraki.DashboardAPI(API_KEY, suppress_logging=True)

serial = (sw_sn) 

port_id = (port)



response = dashboard.switch.getDeviceSwitchPort(serial, port_id)

    

fields = ['portId', 'name', 'enabled', 'poeEnabled', 'type', 'vlan', 'voiceVlan', 'allowedVlans', 'accessPolicyType','isolationEnabled', 'rstpEnabled', 'stpGuard', 'linkNegotiation']

    

for field in fields:

    print (f"{field}: {response[field]}")

        

# Update settings   

def update_values():



    print (Fore.YELLOW,Style.BRIGHT +'\n' + 'Please enter the updated values, which are Case-Sensitive:  ' + '\n')

    

    v_allowed = ""

    mac_allowed = ""

    sticky_mac_allowed = ""

    mac_allowed_limit = ""

    v_vlan = ""

    

    port_name = input ('\n' + 'Port Name:  ')

    enable = input ('Enable Port [True or False]:  ')

    port_type = input ('Port Type [trunk or access]:  ')

    d_vlan = input ('Data VLAN:  ')

    if port_type == ('access'):

        v_vlan = input ('Voice VLAN:  ')

    if port_type == ('trunk'):

        v_allowed = input ('Allowed VLANs [1,3 or 1-3 or All]: ')

    rstp_enabled = input ('RSTP Enable [True or False]:  ')

    stp_guard = input ('STP Guard [disabled, root guard, bpdu guard, loop guard]:  ')

    if port_type == ('access'):

        access_policy = input ('Access Policy [MAC allow list, Open, Sticky MAC allow list]:  ')

    if access_policy == ('MAC allow list'):

       mac_allowed = input ('MAC Address [xx:xx:xx:xx:xx:xx, xx:xx:xx:xx:xx:xx): ')

    if access_policy == ('Sticky MAC allow list'):

        sticky_mac_allowed = input ('MAC Address [xx:xx:xx:xx:xx:xx, xx:xx:xx:xx:xx:xx]: ')

        #mac_allowed_limit = input ('How many MAC Address Allowed: ') Commented until above fixed

    poe_enabled = input ('PoE Enabled [True or False]:  ')





    response_update = {}

    

    if port_name:

        response_update["name"] = port_name

    if enable:

        response_update["enabled"] = enable

    if port_type:

        response_update["type"] = port_type

    if d_vlan != '':

        response_update["vlan"] = d_vlan

    if v_vlan != '':

        response_update["voiceVlan"] = v_vlan

    if v_allowed == '0':

        response_update["allowedVlans"] = v_allowed

    if rstp_enabled:

        response_update["rstpEnabled"] = rstp_enabled

    if stp_guard:

        response_update["stpGuard"] = stp_guard

    if access_policy:

        response_update["accessPolicyType"] = access_policy

    if mac_allowed:

        response_update["macAllowList"] = mac_allowed

    if sticky_mac_allowed:

        response_update["stickyMacAllowList"] = sticky_mac_allowed

    if mac_allowed_limit != '':

        response_update["stickyMacAllowListLimit"]

    if poe_enabled:

        response_update["poeEnabled"] = poe_enabled

    



    fields = response_update

    

    print (Fore.WHITE,Style.BRIGHT + '\n' + 'Here are the values you entered')

    

    for field in fields:

        print (f"{field}: {response_update[field]}")

    

   

    validate = input ('\n' + 'Are all values correct [Y or N]:  ')

 



    if validate in {'Y', 'y'}:



        response = dashboard.switch.updateDeviceSwitchPort(serial, port_id,**response_update,)



        response = dashboard.switch.getDeviceSwitchPort(serial, port_id)



        fields = response_update



        print (Fore.GREEN,Style.BRIGHT + '\n' + 'Here are the New Settings: ' + '\n')



        for field in fields:

            print (f"{field}: {response_update[field]}")



        input  ('\n' + 'Press Enter to return to Main Menu: ')



        main_menu()



    elif validate in {'N', 'n'}:

        input (Fore.MAGENTA + Style.BRIGHT + '\n' + 'Darn, Ok lets try this again, press Enter: ')

        #clearconsole()

        print (Fore.BLUE,Style.BRIGHT +'\n' + 'Current Values:' + '\n')

            

        response = dashboard.switch.getDeviceSwitchPort(serial, port_id)

    

        fields = ['portId', 'name', 'enabled', 'poeEnabled', 'type', 'vlan', 'voiceVlan', 'allowedVlans', 'isolationEnabled', 'rstpEnabled', 'stpGuard', 'linkNegotiation']

    

        for field in fields:

            print (f"{field}: {response[field]}")

                

        update_values()

            

    else:

        print ('you need to select Y,y,N or n')

            

            

update_values()
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Aug 2024 22:23:34 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/stickymacallowlist-error-must-be-an-array/m-p/5444157#M6868</guid>
      <dc:creator>Ed Roche</dc:creator>
      <dc:date>2024-08-19T22:23:34Z</dc:date>
    </item>
    <item>
      <title>Re: stickyMacAllowList error must be an array</title>
      <link>https://community.cisco.com/t5/network-platform-api/stickymacallowlist-error-must-be-an-array/m-p/5444158#M6869</link>
      <description>&lt;P&gt;What I often do for these kinds of problems is create the configuration in the Dashboard, then "Get" the config - and see how the data is formatted.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2024 10:28:46 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/stickymacallowlist-error-must-be-an-array/m-p/5444158#M6869</guid>
      <dc:creator>Philip D'Ath</dc:creator>
      <dc:date>2024-08-20T10:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: stickyMacAllowList error must be an array</title>
      <link>https://community.cisco.com/t5/network-platform-api/stickymacallowlist-error-must-be-an-array/m-p/5444159#M6870</link>
      <description>&lt;P&gt;Should this line:&lt;/P&gt;&lt;PRE class="lia-code-sample language-python"&gt;&lt;CODE&gt;mac_allowed = input ('MAC Address [xx:xx:xx:xx:xx:xx, xx:xx:xx:xx:xx:xx): ')&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;be?&lt;/P&gt;&lt;PRE class="lia-code-sample language-python"&gt;&lt;CODE&gt;mac_allowed = input ('MAC Address [xx:xx:xx:xx:xx:xx, xx:xx:xx:xx:xx:xx]: ')&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Aug 2024 10:30:36 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/stickymacallowlist-error-must-be-an-array/m-p/5444159#M6870</guid>
      <dc:creator>Philip D'Ath</dc:creator>
      <dc:date>2024-08-20T10:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: stickyMacAllowList error must be an array</title>
      <link>https://community.cisco.com/t5/network-platform-api/stickymacallowlist-error-must-be-an-array/m-p/5444160#M6871</link>
      <description>&lt;P&gt;The error is because that variable needs to be a list, but you are using a simple variable.&lt;/P&gt;&lt;P&gt;As &lt;A href="https://community.meraki.com/t5/user/viewprofilepage/user-id/340"&gt;@Philip D'Ath&lt;/A&gt; says, look at an example return data to see which are lists, or look at the API documentation, there is an example response.&lt;/P&gt;&lt;P&gt;I don't see any way for the inquirer library to return a list, you'll just get a string. So you'll need to parse the string into a list.&lt;/P&gt;&lt;P&gt;This might work...&lt;/P&gt;&lt;PRE class="lia-code-sample language-python"&gt;&lt;CODE&gt;m = input ('MAC Address, enter one or more separated by space xx:xx:xx:xx:xx:xx : ')
mac_allowed = list(m.split(" "))&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Aug 2024 12:56:53 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/stickymacallowlist-error-must-be-an-array/m-p/5444160#M6871</guid>
      <dc:creator>sungod</dc:creator>
      <dc:date>2024-08-20T12:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: stickyMacAllowList error must be an array</title>
      <link>https://community.cisco.com/t5/network-platform-api/stickymacallowlist-error-must-be-an-array/m-p/5444161#M6872</link>
      <description>&lt;P&gt;this worked thanks......one last question kind of with this topic.....can we clear the Sticky MAC Address through API, same task as clearing port security on a Cisco switch.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2024 20:14:38 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/stickymacallowlist-error-must-be-an-array/m-p/5444161#M6872</guid>
      <dc:creator>Ed Roche</dc:creator>
      <dc:date>2024-08-20T20:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: stickyMacAllowList error must be an array</title>
      <link>https://community.cisco.com/t5/network-platform-api/stickymacallowlist-error-must-be-an-array/m-p/5444162#M6873</link>
      <description>&lt;P&gt;Not tested.  Try specifying an empty array.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2024 20:36:49 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/stickymacallowlist-error-must-be-an-array/m-p/5444162#M6873</guid>
      <dc:creator>Philip D'Ath</dc:creator>
      <dc:date>2024-08-20T20:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: stickyMacAllowList error must be an array</title>
      <link>https://community.cisco.com/t5/network-platform-api/stickymacallowlist-error-must-be-an-array/m-p/5444163#M6874</link>
      <description>&lt;P&gt;Yeah I thought I did that in the very very beginning but now trying that where I am at now it keeps failing with a error for the value not being a mac address.&lt;/P&gt;&lt;P&gt;I will just try it again from the basic script for that one thing and see what happens. Worse case I will just open another topic&lt;SPAN class="lia-unicode-emoji" title=":winking_face:"&gt;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2024 21:33:30 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/stickymacallowlist-error-must-be-an-array/m-p/5444163#M6874</guid>
      <dc:creator>Ed Roche</dc:creator>
      <dc:date>2024-08-20T21:33:30Z</dc:date>
    </item>
  </channel>
</rss>

