<?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 Using the REST interface for XML API in Automation/API Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-the-rest-interface-for-xml-api/m-p/39006#M900</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Howdy,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have been using the REST interface for pulling reporting and config data using constructed URLs in scripts.&amp;nbsp; All that works well.&amp;nbsp; What I have been unable to do is use the set action for config.&amp;nbsp; I am using a key generated for a sysadmin user, but consistently get an "Unauthorized request" message:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="html" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;&amp;lt;response status="unauth" code="16"&amp;gt;&lt;/P&gt;&lt;DIV id="collapsible1"&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;lt;msg&amp;gt; 
&lt;DIV&gt;&amp;lt;line&amp;gt;Unauthorized request&amp;lt;/line&amp;gt;
&lt;/DIV&gt;&lt;P&gt;&amp;lt;/msg&amp;gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;lt;/response&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using the syntax from the Using the XML API document to send the request:&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="https://server/esp/restapi.esp?type=config&amp;amp;action=set&amp;amp;key=oursecretkey&amp;amp;xpath=devices/entry/vsys/entry/address/entry"&gt;https://server/esp/restapi.esp?type=config&amp;amp;action=set&amp;amp;key=oursecretkey&amp;amp;xpath=devices/entry/vsys/entry/address/entry&lt;/A&gt;&lt;SPAN&gt;[@name='test']&amp;amp;element=&amp;lt;fqdn&amp;gt;test.domain.edu&amp;lt;/fqdn&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this incorrect?&amp;nbsp; Is there more documentation somewhere that can give more detail on how these API URLs should be constructed?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using PANOS 4.0.4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 12 Aug 2011 17:15:56 GMT</pubDate>
    <dc:creator>Dshackelford</dc:creator>
    <dc:date>2011-08-12T17:15:56Z</dc:date>
    <item>
      <title>Using the REST interface for XML API</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-the-rest-interface-for-xml-api/m-p/39006#M900</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Howdy,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have been using the REST interface for pulling reporting and config data using constructed URLs in scripts.&amp;nbsp; All that works well.&amp;nbsp; What I have been unable to do is use the set action for config.&amp;nbsp; I am using a key generated for a sysadmin user, but consistently get an "Unauthorized request" message:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="html" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;&amp;lt;response status="unauth" code="16"&amp;gt;&lt;/P&gt;&lt;DIV id="collapsible1"&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;lt;msg&amp;gt; 
&lt;DIV&gt;&amp;lt;line&amp;gt;Unauthorized request&amp;lt;/line&amp;gt;
&lt;/DIV&gt;&lt;P&gt;&amp;lt;/msg&amp;gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;lt;/response&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using the syntax from the Using the XML API document to send the request:&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="https://server/esp/restapi.esp?type=config&amp;amp;action=set&amp;amp;key=oursecretkey&amp;amp;xpath=devices/entry/vsys/entry/address/entry"&gt;https://server/esp/restapi.esp?type=config&amp;amp;action=set&amp;amp;key=oursecretkey&amp;amp;xpath=devices/entry/vsys/entry/address/entry&lt;/A&gt;&lt;SPAN&gt;[@name='test']&amp;amp;element=&amp;lt;fqdn&amp;gt;test.domain.edu&amp;lt;/fqdn&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this incorrect?&amp;nbsp; Is there more documentation somewhere that can give more detail on how these API URLs should be constructed?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using PANOS 4.0.4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Aug 2011 17:15:56 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-the-rest-interface-for-xml-api/m-p/39006#M900</guid>
      <dc:creator>Dshackelford</dc:creator>
      <dc:date>2011-08-12T17:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using the REST interface for XML API</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-the-rest-interface-for-xml-api/m-p/39007#M901</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can give details of what I actually am trying to do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Custom report that tells me top source IPs of blocked traffic&lt;/P&gt;&lt;P&gt;2. Use API to retrieve list&lt;/P&gt;&lt;P&gt;3. Based on list, create an address object for each source IP&lt;/P&gt;&lt;P&gt;4. Add each address object to an address group that is denied access&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The the deny rule and the address group is already setup, I just need a way for my scripts to manage the addresses in the address group.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Aug 2011 17:25:07 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-the-rest-interface-for-xml-api/m-p/39007#M901</guid>
      <dc:creator>Dshackelford</dc:creator>
      <dc:date>2011-08-12T17:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: Using the REST interface for XML API</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-the-rest-interface-for-xml-api/m-p/39008#M902</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is a great example and I will use it for documenting some API examples next week for a primer I am drafting on working with the XML API.&amp;nbsp; Thank You for the details.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Marc&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Aug 2011 20:21:42 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-the-rest-interface-for-xml-api/m-p/39008#M902</guid>
      <dc:creator>mbenoit</dc:creator>
      <dc:date>2011-08-17T20:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: Using the REST interface for XML API</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-the-rest-interface-for-xml-api/m-p/39009#M903</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's great!&amp;nbsp; I am looking forward to seeing that primer.&amp;nbsp; That is one of our workflows that we hope to setup, but there are others that I would like to implement once I can fully utilize the API.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Aug 2011 22:28:40 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-the-rest-interface-for-xml-api/m-p/39009#M903</guid>
      <dc:creator>Dshackelford</dc:creator>
      <dc:date>2011-08-17T22:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using the REST interface for XML API</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-the-rest-interface-for-xml-api/m-p/39010#M904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try to update your request with the following parameters:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;action=edit&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;xpath=/config/devices/entry/vsys/entry/address/entry&lt;/SPAN&gt;[@name='test']&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Adrien&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Aug 2011 09:06:53 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-the-rest-interface-for-xml-api/m-p/39010#M904</guid>
      <dc:creator>novidys</dc:creator>
      <dc:date>2011-08-18T09:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: Using the REST interface for XML API</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-the-rest-interface-for-xml-api/m-p/39011#M905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That did it!&amp;nbsp; I am on my way to dynamic and automated management of access!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks Novidys.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Aug 2011 12:32:55 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-the-rest-interface-for-xml-api/m-p/39011#M905</guid>
      <dc:creator>Dshackelford</dc:creator>
      <dc:date>2011-08-18T12:32:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using the REST interface for XML API</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-the-rest-interface-for-xml-api/m-p/39012#M906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I now have a script that looks at the top x unauthenticated blocked users in the last 24 hours, and if the repeat count is high enough, it creates an address entry for the ddns FQDN address (so it follows them), adds that address to an address group, which has a captive portal rule applied to force authentication.&amp;nbsp; That way, "good" users are not forced to authenticate, and "bad" users are.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Aug 2011 16:16:45 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-the-rest-interface-for-xml-api/m-p/39012#M906</guid>
      <dc:creator>Dshackelford</dc:creator>
      <dc:date>2011-08-18T16:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: Using the REST interface for XML API</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-the-rest-interface-for-xml-api/m-p/135878#M1335</link>
      <description>&lt;P&gt;This thread is dead by now but on the off chance. Why did you use edit instead of set? I too am getting this unauth error and cannot figure out why because other commands work like system updates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BTW using the pan-python instead but I can try to hit the end point also.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2017 05:00:35 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-the-rest-interface-for-xml-api/m-p/135878#M1335</guid>
      <dc:creator>michaellizhou</dc:creator>
      <dc:date>2017-01-05T05:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: Using the REST interface for XML API</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-the-rest-interface-for-xml-api/m-p/136550#M1337</link>
      <description>&lt;P&gt;You can use 'edit' or 'set. &amp;nbsp;Edit will replace the existing config, Set will add to it. &amp;nbsp;Keep in mind when you use Edit you have to specify the element you're replacing. &amp;nbsp;Here are examples of set and edit&amp;nbsp;used to modify the 'fqdn' of the address object:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;action=set&lt;/LI&gt;&lt;LI&gt;xpath=/config/devices/entry/vsys/entry/address/entry[@name='test']&lt;/LI&gt;&lt;LI&gt;element=&amp;lt;fqdn&amp;gt;test.domain.edu&amp;lt;/fqdn&amp;gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;or&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;action=edit&lt;/LI&gt;&lt;LI&gt;xpath=/config/devices/entry/vsys/entry/address/entry[@name='test']/fqdn&lt;/LI&gt;&lt;LI&gt;element=&amp;lt;fqdn&amp;gt;test.domain.edu&amp;lt;/fqdn&amp;gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For an example like this, set and edit are basically the same, but if you were performing set or edit on the address object, then they are different because set is non-destrictive and will merge the existing config with the new element, while edit is destrictive and will replace the existing address object with the new element.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since you're using pan-python, you might also be interested in a new library from Palo Alto Networks called the Device Framework. &amp;nbsp;It allows you to interact with the API without having touch XML or XPaths. &amp;nbsp;Everything is object oriented so you just create and modify objects in python like you would on the firewall GUI or CLI.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With the Device Framework, the above address object could be created easily using this code. &amp;nbsp;No XML, XPaths, or API-Key required:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;from pandevice import firewall, objects

fw = firewall.Firewall('10.0.0.1', 'admin', 'yourpassword')

address_obj = objects.AddressObject('test', 'test.domain.edu', 'fqdn')

fw.add(address_obj)

address_obj.create()&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;More information about the Palo Alto Networks Device Framework is available here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Documentation&lt;BR /&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;BR /&gt;&lt;BR /&gt;Intro Presentation&lt;BR /&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>Mon, 09 Jan 2017 17:36:49 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-the-rest-interface-for-xml-api/m-p/136550#M1337</guid>
      <dc:creator>btorresgil</dc:creator>
      <dc:date>2017-01-09T17:36:49Z</dc:date>
    </item>
  </channel>
</rss>

