<?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: Unable to execute custom-dynamic-report (502 bad gateway + Unauthorized request) in Automation/API Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/unable-to-execute-custom-dynamic-report-502-bad-gateway/m-p/34886#M835</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;curl doesn't URL-encode your GET QUERY_STRING.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;also, you want to remove the outer &amp;lt;entry&amp;gt; container on your cmd= XML.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Suggest you use POST and try something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;$ curl -k -d "type=report&amp;amp;reporttype=dynamic&amp;amp;reportname=custom-dynamic-report&amp;amp;key=$KEY" --data-urlencode "cmd=&amp;lt;type&amp;gt;&amp;lt;panorama-trsum&amp;gt;&amp;lt;sortby&amp;gt;sessions&amp;lt;/sortby&amp;gt;&amp;lt;aggregate-by&amp;gt;&amp;lt;member&amp;gt;app&amp;lt;/member&amp;gt;&amp;lt;member&amp;gt;srcuser&amp;lt;/member&amp;gt;&amp;lt;/aggregate-by&amp;gt;&amp;lt;values&amp;gt;&amp;lt;member&amp;gt;sessions&amp;lt;/member&amp;gt;&amp;lt;member&amp;gt;bytes&amp;lt;/member&amp;gt;&amp;lt;/values&amp;gt;&amp;lt;/panorama-trsum&amp;gt;&amp;lt;/type&amp;gt;&amp;lt;period&amp;gt;last-24-hrs&amp;lt;/period&amp;gt;&amp;lt;topn&amp;gt;50&amp;lt;/topn&amp;gt;&amp;lt;topm&amp;gt;10&amp;lt;/topm&amp;gt;&amp;lt;caption&amp;gt;office-user-report&amp;lt;/caption&amp;gt;&amp;lt;query&amp;gt;(addr in '192.168.1.0/24') and (app neq dns) and (app neq ntp)&amp;lt;/query&amp;gt;" &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://172.25.1.251/api/" rel="nofollow"&gt;https://172.25.1.251/api/&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 18 May 2015 20:45:18 GMT</pubDate>
    <dc:creator>ksteves1</dc:creator>
    <dc:date>2015-05-18T20:45:18Z</dc:date>
    <item>
      <title>Unable to execute custom-dynamic-report (502 bad gateway + Unauthorized request)</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/unable-to-execute-custom-dynamic-report-502-bad-gateway/m-p/34885#M834</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to create and execute a completely dynamic report as described in 2.5.3 Custom reports in this XML API documentation [1]. This reporting is being performed on a panorama running PANOS-6.0.3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I try to download a report I get the following error (I've tried a few different methods of URL encoding as curl doesn't like the [ and @ characters]):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;curl -k "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://x.x.x.x/api/?type=config&amp;amp;action=get&amp;amp;key=redacted=&amp;amp;path=/config/devices/entry/vsys/entry%5B%40name%3D%27vsys1%27%5D/reports/entry%5B%40name='office-user-report%27%5D" rel="nofollow"&gt;https://x.x.x.x/api/?type=config&amp;amp;action=get&amp;amp;key=redacted=&amp;amp;path=/config/devices/entry/vsys/entry%5B%40name%3D%27vsys1%27%5D/reports/entry%5B%40name='office-user-report%27%5D&lt;/A&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;response status="unauth" code="16"&amp;gt;&amp;lt;msg&amp;gt;&amp;lt;line&amp;gt;Unauthorized request&amp;lt;/line&amp;gt;&amp;lt;/msg&amp;gt;&amp;lt;/response&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then exported the configuration in XML form to get access to the raw underlying report definition and tried to execute it directly as follows&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;curl -k "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://x.x.x.x/api/?type=report&amp;amp;reporttype=dynamic&amp;amp;reportname=custom-dynamic-report&amp;amp;key=redacted=&amp;amp;cmd=" rel="nofollow"&gt;https://x.x.x.x/api/?type=report&amp;amp;reporttype=dynamic&amp;amp;reportname=custom-dynamic-report&amp;amp;key=redacted=&amp;amp;cmd=&lt;/A&gt;&lt;SPAN&gt;&amp;lt;entry name=\"office-user-report\"&amp;gt;&amp;lt;type&amp;gt;&amp;lt;panorama-trsum&amp;gt;&amp;lt;sortby&amp;gt;sessions&amp;lt;/sortby&amp;gt;&amp;lt;aggregate-by&amp;gt;&amp;lt;member&amp;gt;app&amp;lt;/member&amp;gt;&amp;lt;member&amp;gt;srcuser&amp;lt;/member&amp;gt;&amp;lt;/aggregate-by&amp;gt;&amp;lt;values&amp;gt;&amp;lt;member&amp;gt;sessions&amp;lt;/member&amp;gt;&amp;lt;member&amp;gt;bytes&amp;lt;/member&amp;gt;&amp;lt;/values&amp;gt;&amp;lt;/panorama-trsum&amp;gt;&amp;lt;/type&amp;gt;&amp;lt;period&amp;gt;last-24-hrs&amp;lt;/period&amp;gt;&amp;lt;topn&amp;gt;50&amp;lt;/topn&amp;gt;&amp;lt;topm&amp;gt;10&amp;lt;/topm&amp;gt;&amp;lt;caption&amp;gt;office-user-report&amp;lt;/caption&amp;gt;&amp;lt;query&amp;gt;(addr in '192.168.1.0/24') and (app neq dns) and (app neq ntp)&amp;lt;/query&amp;gt;&amp;lt;/entry&amp;gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I always receive back a bad gateway response:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;html&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;502 Bad Gateway&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;body bgcolor="white"&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;center&amp;gt;&amp;lt;h1&amp;gt;502 Bad Gateway&amp;lt;/h1&amp;gt;&amp;lt;/center&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;hr&amp;gt;&amp;lt;center&amp;gt;&amp;lt;/center&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/body&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/html&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a support case open on this issue as well, please contact me privately if you would like it, it's associated with this support account.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[1] &lt;/SPAN&gt;&lt;A class="" href="https://live.paloaltonetworks.com/servlet/JiveServlet/previewBody/6607-102-11-31905/XML-API-6.0.pdf"&gt;https://live.paloaltonetworks.com/servlet/JiveServlet/previewBody/6607-102-11-31905/XML-API-6.0.pdf&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Feb 2015 14:55:00 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/unable-to-execute-custom-dynamic-report-502-bad-gateway/m-p/34885#M834</guid>
      <dc:creator>johnfstack8</dc:creator>
      <dc:date>2015-02-26T14:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to execute custom-dynamic-report (502 bad gateway + Unauthorized request)</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/unable-to-execute-custom-dynamic-report-502-bad-gateway/m-p/34886#M835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;curl doesn't URL-encode your GET QUERY_STRING.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;also, you want to remove the outer &amp;lt;entry&amp;gt; container on your cmd= XML.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Suggest you use POST and try something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;$ curl -k -d "type=report&amp;amp;reporttype=dynamic&amp;amp;reportname=custom-dynamic-report&amp;amp;key=$KEY" --data-urlencode "cmd=&amp;lt;type&amp;gt;&amp;lt;panorama-trsum&amp;gt;&amp;lt;sortby&amp;gt;sessions&amp;lt;/sortby&amp;gt;&amp;lt;aggregate-by&amp;gt;&amp;lt;member&amp;gt;app&amp;lt;/member&amp;gt;&amp;lt;member&amp;gt;srcuser&amp;lt;/member&amp;gt;&amp;lt;/aggregate-by&amp;gt;&amp;lt;values&amp;gt;&amp;lt;member&amp;gt;sessions&amp;lt;/member&amp;gt;&amp;lt;member&amp;gt;bytes&amp;lt;/member&amp;gt;&amp;lt;/values&amp;gt;&amp;lt;/panorama-trsum&amp;gt;&amp;lt;/type&amp;gt;&amp;lt;period&amp;gt;last-24-hrs&amp;lt;/period&amp;gt;&amp;lt;topn&amp;gt;50&amp;lt;/topn&amp;gt;&amp;lt;topm&amp;gt;10&amp;lt;/topm&amp;gt;&amp;lt;caption&amp;gt;office-user-report&amp;lt;/caption&amp;gt;&amp;lt;query&amp;gt;(addr in '192.168.1.0/24') and (app neq dns) and (app neq ntp)&amp;lt;/query&amp;gt;" &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://172.25.1.251/api/" rel="nofollow"&gt;https://172.25.1.251/api/&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 May 2015 20:45:18 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/unable-to-execute-custom-dynamic-report-502-bad-gateway/m-p/34886#M835</guid>
      <dc:creator>ksteves1</dc:creator>
      <dc:date>2015-05-18T20:45:18Z</dc:date>
    </item>
  </channel>
</rss>

