<?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: mx_firewall_control.py invalid format txt or json in Network Platform API</title>
    <link>https://community.cisco.com/t5/network-platform-api/mx-firewall-control-py-invalid-format-txt-or-json/m-p/5442537#M6605</link>
    <description>&lt;P&gt;Hello, &lt;/P&gt;&lt;P&gt;OK thank you, I will check this week.&lt;/P&gt;</description>
    <pubDate>Fri, 04 Aug 2023 08:53:50 GMT</pubDate>
    <dc:creator>maxencecolson</dc:creator>
    <dc:date>2023-08-04T08:53:50Z</dc:date>
    <item>
      <title>mx_firewall_control.py invalid format txt or json</title>
      <link>https://community.cisco.com/t5/network-platform-api/mx-firewall-control-py-invalid-format-txt-or-json/m-p/5442533#M6601</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I try to use the script mx_firewall_control.py to update rulesets L3 but I've got a error message with the commands to add a ruleset.&lt;/P&gt;&lt;PRE class="lia-code-sample language-markup"&gt;&lt;CODE&gt;PS C:\Meraki Python Scripts&amp;gt; python mxfirewallcontrol.py -o "XXXXX" -f "type:network, name: Template site MX67" -c append-file:update_input.txt
2023-07-20 18:43:07 -- Retrieving organization info...
GET https://api.meraki.com/api/v1/organizations
200
2023-07-20 18:43:07 -- Selecting networks and templates according to filters... GET https://api.meraki.com/api/v1/organizations/YYYYY/networks
200
2023-07-20 18:43:08 -- SIMULATION MODE. CHANGES WILL NOT BE SAVED. USE "-m commit" TO OVERRIDE
2023-07-20 18:43:08 -- ERROR 28: Invalid input file format "update_input.txt" 2023-07-20 18:43:08 -- ERROR: Unable to load source ruleset&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But I think to follow and apply correctly the format for the file as explained on the README (to be honest, it's just a test so I don't modify a lot the template txt file provided). Also the txt file is in the same folder than the .PY.&lt;/P&gt;&lt;P&gt;Below the extract of the txt file (1 line per rule):&lt;/P&gt;&lt;PRE class="lia-code-sample language-markup"&gt;&lt;CODE&gt;{"protocol":"any", "srcPort":"Any", "srcCidr":"10.1.1.1", "destPort":"Any","destCidr":"any", "policy":"deny", "syslogEnabled":false, "comment":"Line 1"}
{"protocol":"any", "srcPort":"Any", "srcCidr":"10.2.2.2", "destPort":"Any","destCidr":"any", "policy":"deny", "syslogEnabled":false, "comment":"Line 2"}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;Also I tried to use the direct command, and I've the same type of error with an invalid format.&lt;/P&gt;&lt;PRE class="lia-code-sample language-markup"&gt;&lt;CODE&gt;PS C:\Meraki Python Scripts&amp;gt; python mxfirewallcontrol.py -o "XXXXX" -f"type:network, name:Template site MX67" -c insert:1:"[{""protocol"":""any"", ""srcPort"":""Any"", ""srcCidr"":""10.6.0.1"", ""destPort"":""Any"", ""destCidr"":""any"", ""policy"":""deny"", ""syslogEnabled"":false, ""comment"":""Line 3""}]" -m commit
2023-07-20 18:59:43 -- Retrieving organization info...
GET https://api.meraki.com/api/v1/organizations
200
2023-07-20 18:59:44 -- Selecting networks and templates according to filters... GET https://api.meraki.com/api/v1/organizations/YYYYY/networks
200
2023-07-20 18:59:44 -- SIMULATION MODE. CHANGES WILL NOT BE SAVED. USE "-m commit" TO OVERRIDE
2023-07-20 18:59:44 -- ERROR: ERROR 50: Ruleset to be added must be given in JSON format&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;What I'm doing wrong ?&lt;/P&gt;&lt;P&gt;Here the source code: &lt;A href="https://github.com/meraki/automation-scripts/tree/master/mx_firewall_control" target="_self" rel="nofollow noopener noreferrer"&gt;GITHUB Automation Meraki&lt;/A&gt;&lt;/P&gt;&lt;P&gt;PS1: I don't have any issue for the "print" command&lt;BR /&gt;PS2: I use Windows10/Visual Studio Code to launch the script.&lt;/P&gt;&lt;P&gt;In advance, thank you very much&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2023 11:54:26 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/mx-firewall-control-py-invalid-format-txt-or-json/m-p/5442533#M6601</guid>
      <dc:creator>maxencecolson</dc:creator>
      <dc:date>2023-07-21T11:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: mx_firewall_control.py invalid format txt or json</title>
      <link>https://community.cisco.com/t5/network-platform-api/mx-firewall-control-py-invalid-format-txt-or-json/m-p/5442534#M6602</link>
      <description>&lt;P&gt;Try changing (this and the other references) from:&lt;BR /&gt;"srcCidr":"10.1.1.1"&lt;BR /&gt;to:&lt;BR /&gt;"srcCidr":"10.1.1.1/32"&lt;/P&gt;&lt;P&gt;So it is in CIDR format.&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jul 2023 00:41:22 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/mx-firewall-control-py-invalid-format-txt-or-json/m-p/5442534#M6602</guid>
      <dc:creator>Philip D'Ath</dc:creator>
      <dc:date>2023-07-23T00:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: mx_firewall_control.py invalid format txt or json</title>
      <link>https://community.cisco.com/t5/network-platform-api/mx-firewall-control-py-invalid-format-txt-or-json/m-p/5442535#M6603</link>
      <description>&lt;P&gt;Actually it is saying "Ruleset to be added must be given in JSON format".  Your example you supplied looks like well formed JSON to me.&lt;/P&gt;&lt;P&gt;Perhaps trying breaking the file in two, and loading one half and then the other, and then narrowing it down from there.  There must be an error in the source file.&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jul 2023 00:43:40 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/mx-firewall-control-py-invalid-format-txt-or-json/m-p/5442535#M6603</guid>
      <dc:creator>Philip D'Ath</dc:creator>
      <dc:date>2023-07-23T00:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: mx_firewall_control.py invalid format txt or json</title>
      <link>https://community.cisco.com/t5/network-platform-api/mx-firewall-control-py-invalid-format-txt-or-json/m-p/5442536#M6604</link>
      <description>&lt;P&gt;The JSON objects you provided seem to be correctly formatted, and there are no obvious syntax errors or missing commas.&lt;/P&gt;&lt;P&gt;The issue might be related to how the input data is being passed to the script, or how the script reads the input file?&lt;/P&gt;&lt;P&gt;Ensure that the &lt;STRONG&gt;&lt;EM&gt;update_input.txt&lt;/EM&gt;&lt;/STRONG&gt; file is saved with the proper encoding, such as UTF-8. You can check and change the encoding in Visual Studio Code by clicking on the "File" menu, then "Save with Encoding," and select "UTF-8" if it's not already set.&lt;/P&gt;&lt;P&gt;Otherwise, I reviewed the&lt;SPAN&gt; function &lt;EM&gt;&lt;STRONG&gt;loadruleset&lt;/STRONG&gt; (responsible for loading a ruleset from a file and returning it as a list of JSON objects (rules)) &lt;/EM&gt;catches any exceptions that occur during JSON parsing using a general &lt;/SPAN&gt;except&lt;SPAN&gt; block&lt;/SPAN&gt; so try to add some print statements to debug the function and check the values of &lt;EM&gt;p_filepath&lt;/EM&gt;, &lt;EM&gt;buffer&lt;/EM&gt;, &lt;EM&gt;jdump&lt;/EM&gt; and the detailed exception at different stages to see if they match your expectations.&lt;/P&gt;&lt;P&gt;Let me knew &lt;SPAN&gt;If the issues persist!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2023 12:21:10 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/mx-firewall-control-py-invalid-format-txt-or-json/m-p/5442536#M6604</guid>
      <dc:creator>badreddine</dc:creator>
      <dc:date>2023-07-24T12:21:10Z</dc:date>
    </item>
    <item>
      <title>Re: mx_firewall_control.py invalid format txt or json</title>
      <link>https://community.cisco.com/t5/network-platform-api/mx-firewall-control-py-invalid-format-txt-or-json/m-p/5442537#M6605</link>
      <description>&lt;P&gt;Hello, &lt;/P&gt;&lt;P&gt;OK thank you, I will check this week.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2023 08:53:50 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/mx-firewall-control-py-invalid-format-txt-or-json/m-p/5442537#M6605</guid>
      <dc:creator>maxencecolson</dc:creator>
      <dc:date>2023-08-04T08:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: mx_firewall_control.py invalid format txt or json</title>
      <link>https://community.cisco.com/t5/network-platform-api/mx-firewall-control-py-invalid-format-txt-or-json/m-p/5442538#M6606</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I solved the issue with text file. it's required to add and an "ENTER"/"RETURN" at the end of the file.&lt;/P&gt;&lt;P&gt;Regarding the other issue, I don't find the solution but you can close this topic, my main use is with the text file method.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 09:10:28 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/mx-firewall-control-py-invalid-format-txt-or-json/m-p/5442538#M6606</guid>
      <dc:creator>maxencecolson</dc:creator>
      <dc:date>2023-08-09T09:10:28Z</dc:date>
    </item>
  </channel>
</rss>

