<?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: XML API config action 'set' in Automation/API Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/xml-api-config-action-set/m-p/128443#M1304</link>
    <description>&lt;P&gt;Thanks, I'll have to look into pandevice more. I keep hearing that it's really nice and easier to use.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Nov 2016 13:55:20 GMT</pubDate>
    <dc:creator>BPry</dc:creator>
    <dc:date>2016-11-23T13:55:20Z</dc:date>
    <item>
      <title>XML API config action 'set'</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/xml-api-config-action-set/m-p/128286#M1302</link>
      <description>&lt;P&gt;Okay, I still can't figure this guy out. All the other commands work perfectly fine but as soon as I try to 'set' a new rule I get an error saying that it's malformed. I've looked through all of the documentation that I can find but nothing will get the request to come across properly&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://10.191.136.7/api/?type=config&amp;amp;action=set&amp;amp;key=" target="_blank"&gt;https://10.191.136.7/api/?type=config&amp;amp;action=set&amp;amp;key=&lt;/A&gt;&lt;EM&gt;key&lt;/EM&gt;&amp;amp;xpath=/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/rulebase/security/rules/entry[@name='Test-API']&amp;amp;element=&amp;lt;source&amp;gt;&amp;lt;member&amp;gt;10.191.135.66&amp;lt;/member&amp;gt;&amp;lt;/source&amp;gt;&amp;lt;destination&amp;gt;&amp;lt;member&amp;gt;8.8.8.8&amp;lt;/member&amp;gt;&amp;lt;/destination&amp;gt;&amp;lt;service&amp;gt;&amp;lt;member&amp;gt;any&amp;lt;/member&amp;gt;&amp;lt;/service&amp;gt;&amp;lt;application&amp;gt;&amp;lt;member&amp;gt;any&amp;lt;/member&amp;gt;&amp;lt;/application&amp;gt;&amp;lt;action&amp;gt;allow&amp;lt;/action&amp;gt;&amp;lt;source-user&amp;gt;&amp;lt;member&amp;gt;any&amp;lt;/member&amp;gt;&amp;lt;/source-user&amp;gt;&amp;lt;option&amp;gt;&amp;lt;disable-server-response-inspection&amp;gt;no&amp;lt;/disable-server-response-inspection&amp;gt;&amp;lt;/option&amp;gt;&amp;lt;negate-source&amp;gt;no&amp;lt;/negate-source&amp;gt;&amp;lt;negatedestination&amp;gt;no&amp;lt;/negate-destination&amp;gt;&amp;lt;disabled&amp;gt;yes&amp;lt;/disabled&amp;gt;&amp;lt;log-start&amp;gt;no&amp;lt;/log-start&amp;gt;&amp;lt;logend&amp;gt;yes&amp;lt;/log-end&amp;gt;&amp;lt;description&amp;gt;Testing&amp;lt;/description&amp;gt;&amp;lt;from&amp;gt;&amp;lt;member&amp;gt;inside&amp;lt;/member&amp;gt;&amp;lt;/from&amp;gt;&amp;lt;to&amp;gt;&amp;lt;member&amp;gt;outside&amp;lt;/member&amp;gt;&amp;lt;/to&amp;gt;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Nov 2016 19:57:50 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/xml-api-config-action-set/m-p/128286#M1302</guid>
      <dc:creator>BPry</dc:creator>
      <dc:date>2016-11-22T19:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: XML API config action 'set'</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/xml-api-config-action-set/m-p/128346#M1303</link>
      <description>&lt;P&gt;There are two things to change:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. &amp;nbsp;There is a hiphen missing from two of your elements: &amp;nbsp;logend should be log-end, and negatedestination should be negate-destination&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. &amp;nbsp;I recommend to always give your 'element' parameter a root element. &amp;nbsp;So rather than start with &amp;lt;source&amp;gt; and end with &amp;lt;/to&amp;gt;, you should start with &amp;lt;entry name='Test-API'&amp;gt; and end with &amp;lt;/entry&amp;gt;. &amp;nbsp;That way the beginning and end of the tags match. &amp;nbsp;Of course, this means removing '/entry[@name='Test-API'] from the end of your xpath.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In summary, this API call should work for you:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;https://10.191.136.7/api/?type=config&amp;amp;action=set&amp;amp;key=key&amp;amp;xpath=/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/rulebase/security/rules&amp;amp;element=&amp;lt;entry name='Test-API'&amp;gt;&amp;lt;source&amp;gt;&amp;lt;member&amp;gt;10.191.135.66&amp;lt;/member&amp;gt;&amp;lt;/source&amp;gt;&amp;lt;destination&amp;gt;&amp;lt;member&amp;gt;8.8.8.8&amp;lt;/member&amp;gt;&amp;lt;/destination&amp;gt;&amp;lt;service&amp;gt;&amp;lt;member&amp;gt;any&amp;lt;/member&amp;gt;&amp;lt;/service&amp;gt;&amp;lt;application&amp;gt;&amp;lt;member&amp;gt;any&amp;lt;/member&amp;gt;&amp;lt;/application&amp;gt;&amp;lt;action&amp;gt;allow&amp;lt;/action&amp;gt;&amp;lt;source-user&amp;gt;&amp;lt;member&amp;gt;any&amp;lt;/member&amp;gt;&amp;lt;/source-user&amp;gt;&amp;lt;option&amp;gt;&amp;lt;disable-server-response-inspection&amp;gt;no&amp;lt;/disable-server-response-inspection&amp;gt;&amp;lt;/option&amp;gt;&amp;lt;negate-source&amp;gt;no&amp;lt;/negate-source&amp;gt;&amp;lt;negate-destination&amp;gt;no&amp;lt;/negate-destination&amp;gt;&amp;lt;disabled&amp;gt;yes&amp;lt;/disabled&amp;gt;&amp;lt;log-start&amp;gt;no&amp;lt;/log-start&amp;gt;&amp;lt;log-end&amp;gt;yes&amp;lt;/log-end&amp;gt;&amp;lt;description&amp;gt;Testing&amp;lt;/description&amp;gt;&amp;lt;from&amp;gt;&amp;lt;member&amp;gt;inside&amp;lt;/member&amp;gt;&amp;lt;/from&amp;gt;&amp;lt;to&amp;gt;&amp;lt;member&amp;gt;outside&amp;lt;/member&amp;gt;&amp;lt;/to&amp;gt;&amp;lt;/entry&amp;gt;&lt;/PRE&gt;&lt;P&gt;If you're using python, you might consider using pan-python or Palo Alto Networks Device Framework to craft your API calls to eliminate these pesky XML/Xpath issues. &amp;nbsp;For example, here's how you would make the same API call using the Device Framework in python:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;from pandevice import firewall, policies

fw = firewall.Firewall('10.191.136.7', 'admin', 'yourpassword')

rulebase = fw.add(policies.Rulebase())

rule1 = policies.SecurityRule('Test-API',
                              source='10.181.135.66',
                              destination='8.8.8.8',
                              fromzone='inside',
                              tozone='outside',
                              action='allow',
                              description='testing')
rulebase.add(rule1)
rule1.create()&lt;/PRE&gt;&lt;P&gt;In this example, you don't need to mess&amp;nbsp;with XML or XPaths to create the security rule. &amp;nbsp;More information about the Palo Alto Networks Device Framework is availabe here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Documentation&lt;/P&gt;&lt;P&gt;&lt;A href="http://pandevice.readthedocs.io/en/latest/readme.html" target="_blank"&gt;http://pandevice.readthedocs.io/en/latest/readme.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Presentation&lt;/P&gt;&lt;P&gt;&lt;A href="http://paloaltonetworks.github.io/pandevice/" target="_blank"&gt;http://paloaltonetworks.github.io/pandevice/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2016 02:50:25 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/xml-api-config-action-set/m-p/128346#M1303</guid>
      <dc:creator>btorresgil</dc:creator>
      <dc:date>2016-11-23T02:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: XML API config action 'set'</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/xml-api-config-action-set/m-p/128443#M1304</link>
      <description>&lt;P&gt;Thanks, I'll have to look into pandevice more. I keep hearing that it's really nice and easier to use.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2016 13:55:20 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/xml-api-config-action-set/m-p/128443#M1304</guid>
      <dc:creator>BPry</dc:creator>
      <dc:date>2016-11-23T13:55:20Z</dc:date>
    </item>
  </channel>
</rss>

