<?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: Updating Trunk port settings and getting error in Network Platform API</title>
    <link>https://community.cisco.com/t5/network-platform-api/updating-trunk-port-settings-and-getting-error/m-p/5410793#M1915</link>
    <description>&lt;P&gt;I believe this is because when a port is set to access mode, the Meraki API expects an accessPolicyType field to be present. If this field is missing or mismatched, it can cause update errors. On the other hand, when the port is in trunk mode, the API rejects any access policy fields as they are not applicable.&lt;/P&gt;</description>
    <pubDate>Tue, 24 Jun 2025 16:14:19 GMT</pubDate>
    <dc:creator>aleabrahao</dc:creator>
    <dc:date>2025-06-24T16:14:19Z</dc:date>
    <item>
      <title>Updating Trunk port settings and getting error</title>
      <link>https://community.cisco.com/t5/network-platform-api/updating-trunk-port-settings-and-getting-error/m-p/5410787#M1909</link>
      <description>&lt;P&gt;Hi All&lt;/P&gt;&lt;P&gt;Attached is my code for a function to update port settings on a switch (dashboard.switch.updateDeviceSwitchPort). When I do a trunk port it keeps telling me it can't update the access policy of the port which I know that and I am not updating. The code is a little long sorry about that but if you can take a look and see if something stands out it would be much appreciated&lt;/P&gt;&lt;PRE class="lia-code-sample language-python"&gt;&lt;CODE&gt;# 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 = ""
            sticky_allowed_limit = ""
            rstp_enabled = "True"
            stp_guard = "bpdu guard"
            native_vlan = ""
            d_vlan = ""
            access_policy = ""

            port_name = input ('\n' + 'Port Name:  ')
            enable = input ('Enable Port [True or False]:  ')
            port_type = input ('Port Type [trunk or access] required:  ')
            
            if port_type == ('access'):
                d_vlan = input ('Data VLAN:  ')
                v_vlan = input ('Voice VLAN:  ')
                access_policy = input ('Access Policy [(O)pen, (S)ticky MAC ] required:  ')

                if access_policy == ('S'):
                    access_policy = 'Sticky MAC allow list'
                    mac_allowed_limit = input ('How many MAC Address Allowed: ')
                if access_policy == ('O'):
                    access_policy = "Open"
                    
                            
            if port_type == ('trunk'):
                native_vlan = input ('Native VLAN: ')
                v_allowed = input ('Allowed VLANs [1,3 or 1-3 or All]: ')
            
            
            poe_enabled = input ('PoE Enabled [True or False]:  ')


            response_update = {}
    
            if port_type == "access":
                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 rstp_enabled:
                    response_update["rstpEnabled"] = rstp_enabled
                if stp_guard:
                    response_update["stpGuard"] = stp_guard
                if access_policy:
                    #response_update["accessPolicyType"] = access_policy
                if sticky_mac_allowed:
                    response_update["stickyMacAllowList"] = sticky_mac_allowed
                if mac_allowed_limit:
                    response_update["stickyMacAllowListLimit"] = mac_allowed_limit
                if poe_enabled:
                    response_update["poeEnabled"] = poe_enabled
            
            if port_type == "trunk":
                if port_name: 
                    response_update["name"] = port_name
                if enable:
                    response_update["enabled"] = enable
                if port_type:
                    response_update["type"] = port_type
                if native_vlan:
                    response_update["vlan"] = native_vlan
                if v_allowed:
                    response_update["allowedVlans"] = v_allowed
                if rstp_enabled:
                   response_update["rstpEnabled"] = "True"
                if stp_guard:
                   response_update["stpGuard"] = "disabled"


            fields = response_update
            clearconsole()
            print (Fore.BLUE,Style.BRIGHT + '\n' + 'Here are the values you entered')
            print ('\n')
            for field in fields:
            
                print (Fore.YELLOW + f"{field}: " + Fore.WHITE + f"{response_update[field]}")
    
   
            validate = input ('\n' + 'Are all values correct [Y or N]:  ')
 

            if validate in {'Y', 'y'}:
                clearconsole()
                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'}:
                clearconsole()
                input (Fore.MAGENTA + Style.BRIGHT + '\n' + 'Darn, Ok lets try this again, press Enter: ')
                #clearconsole()
                print (Fore.YELLOW,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 or N!')
                restart = input ('Hit Enter!')
                if restart == "":
                    update_values()
            
            
        update_values()    &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jun 2025 15:23:00 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/updating-trunk-port-settings-and-getting-error/m-p/5410787#M1909</guid>
      <dc:creator>Ed Roche</dc:creator>
      <dc:date>2025-06-24T15:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Trunk port settings and getting error</title>
      <link>https://community.cisco.com/t5/network-platform-api/updating-trunk-port-settings-and-getting-error/m-p/5410788#M1910</link>
      <description>&lt;P&gt;General comment: it's called 'update', but the logic looks like...&lt;/P&gt;&lt;P&gt;prompt human for values - what if the human lies about the current port type?&lt;/P&gt;&lt;P&gt;call the update endpoint&lt;/P&gt;&lt;P&gt;Whereas, IMO more logical would be...&lt;/P&gt;&lt;P&gt;call get endpoint to get current elements and values&lt;/P&gt;&lt;P&gt;prompt human with current elements/values and option to change value&lt;/P&gt;&lt;P&gt;call update endpoint&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jun 2025 15:47:27 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/updating-trunk-port-settings-and-getting-error/m-p/5410788#M1910</guid>
      <dc:creator>sungod</dc:creator>
      <dc:date>2025-06-24T15:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Trunk port settings and getting error</title>
      <link>https://community.cisco.com/t5/network-platform-api/updating-trunk-port-settings-and-getting-error/m-p/5410789#M1911</link>
      <description>&lt;P&gt;In your update_values() function, you have this block.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if access_policy:&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;#response_update["accessPolicyType"] = access_policy&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Even though it's commented out, if you uncomment it or if access_policy is set , it might still be included in the payload when updating a trunk port, which does not support access policies.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jun 2025 15:53:59 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/updating-trunk-port-settings-and-getting-error/m-p/5410789#M1911</guid>
      <dc:creator>aleabrahao</dc:creator>
      <dc:date>2025-06-24T15:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Trunk port settings and getting error</title>
      <link>https://community.cisco.com/t5/network-platform-api/updating-trunk-port-settings-and-getting-error/m-p/5410790#M1912</link>
      <description>&lt;P&gt;So, you think showing each value individually and giving opportunity to update then sending the update right away will work? I am currently showing all the current values for the endpoint, going through each setting to have option to update, then adding to the dictionary, and finally updating the values on the device. &lt;/P&gt;</description>
      <pubDate>Tue, 24 Jun 2025 16:03:35 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/updating-trunk-port-settings-and-getting-error/m-p/5410790#M1912</guid>
      <dc:creator>Ed Roche</dc:creator>
      <dc:date>2025-06-24T16:03:35Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Trunk port settings and getting error</title>
      <link>https://community.cisco.com/t5/network-platform-api/updating-trunk-port-settings-and-getting-error/m-p/5410791#M1913</link>
      <description>&lt;P&gt;thanks for reply&lt;/P&gt;&lt;P&gt;I just tried starting out with the port as a trunk then I was able to update the setting just fine. I guess if it is an access port it has the access_policy value. Weird.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jun 2025 16:08:41 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/updating-trunk-port-settings-and-getting-error/m-p/5410791#M1913</guid>
      <dc:creator>Ed Roche</dc:creator>
      <dc:date>2025-06-24T16:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Trunk port settings and getting error</title>
      <link>https://community.cisco.com/t5/network-platform-api/updating-trunk-port-settings-and-getting-error/m-p/5410792#M1914</link>
      <description>&lt;P&gt;it looks like as long as the access_policy is se to Open its fine so maybe I can hardcode the Open value&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jun 2025 16:10:57 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/updating-trunk-port-settings-and-getting-error/m-p/5410792#M1914</guid>
      <dc:creator>Ed Roche</dc:creator>
      <dc:date>2025-06-24T16:10:57Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Trunk port settings and getting error</title>
      <link>https://community.cisco.com/t5/network-platform-api/updating-trunk-port-settings-and-getting-error/m-p/5410793#M1915</link>
      <description>&lt;P&gt;I believe this is because when a port is set to access mode, the Meraki API expects an accessPolicyType field to be present. If this field is missing or mismatched, it can cause update errors. On the other hand, when the port is in trunk mode, the API rejects any access policy fields as they are not applicable.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jun 2025 16:14:19 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/updating-trunk-port-settings-and-getting-error/m-p/5410793#M1915</guid>
      <dc:creator>aleabrahao</dc:creator>
      <dc:date>2025-06-24T16:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: Updating Trunk port settings and getting error</title>
      <link>https://community.cisco.com/t5/network-platform-api/updating-trunk-port-settings-and-getting-error/m-p/5410794#M1916</link>
      <description>&lt;P&gt;Hardcoding under the Trunk section worked. Like you said since it already had Sticky set it was passing that value&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jun 2025 16:18:11 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/updating-trunk-port-settings-and-getting-error/m-p/5410794#M1916</guid>
      <dc:creator>Ed Roche</dc:creator>
      <dc:date>2025-06-24T16:18:11Z</dc:date>
    </item>
  </channel>
</rss>

