<?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 API Powershell script fails with specific Invoke-WebRequest call in Automation/API Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/api-powershell-script-fails-with-specific-invoke-webrequest-call/m-p/303192#M2091</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to create a restful api call against our firewall to map historical QoS Statistics on a certain interface.&lt;/P&gt;&lt;P&gt;I've seemed to come across an issue that's not working and I was hoping you could help.&lt;/P&gt;&lt;P&gt;First question first: the information that I'm trying to get is the QoS Statistics (Network -&amp;gt; QoS -&amp;gt; Statistics)&lt;/P&gt;&lt;P&gt;Has that been exposed by SNMP in any recent PANos versions?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;if not here's my issue:&lt;/P&gt;&lt;P&gt;Here's the command I'm trying to use to retrieve information in the API call: show qos interface ethernet1/2 throughput 0&lt;/P&gt;&lt;P&gt;I've verify the syntax to use running the following commands on the FW console:&lt;/P&gt;&lt;P&gt;debug cli on&lt;BR /&gt;show qos interface ethernet1/2 throughput 0&lt;/P&gt;&lt;P&gt;I get:&lt;/P&gt;&lt;P&gt;(container-tag: qos container-tag: interface container-tag: entry key-tag: name value: ethernet1/2 leaf-tag: throughput value: 0 pop-tag: pop-tag:)&lt;BR /&gt;((eol-matched: . #t) (context-inserted-at-end-p: . #f))&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;lt;request cmd="op" cookie="05...34" uid="502"&amp;gt;&amp;lt;operations&amp;gt;&amp;lt;show&amp;gt;&amp;lt;qos&amp;gt;&lt;BR /&gt;&amp;lt;interface&amp;gt;&amp;lt;entry name='ethernet1/2'&amp;gt;&amp;lt;throughput&amp;gt;0&amp;lt;/throughput&amp;gt;&amp;lt;/entry&amp;gt;&amp;lt;/interface&amp;gt;&lt;BR /&gt;&amp;lt;/qos&amp;gt;&amp;lt;/show&amp;gt;&amp;lt;/operations&amp;gt;&amp;lt;/request&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;2019-12-10 15:15:27&lt;BR /&gt;&amp;lt;response status="success"&amp;gt;&amp;lt;result&amp;gt;&amp;lt;![CDATA[Class 1 0 kbps&lt;BR /&gt;Class 2 16590 kbps&lt;BR /&gt;Class 3 35469 kbps&lt;BR /&gt;Class 4 309 kbps&lt;BR /&gt;Class 5 51859 kbps&lt;BR /&gt;Class 6 13692 kbps&lt;BR /&gt;Class 7 424 kbps&lt;BR /&gt;Class 8 0 kbps&lt;BR /&gt;]]&amp;gt;&amp;lt;/result&amp;gt;&amp;lt;/response&amp;gt;&lt;/P&gt;&lt;P&gt;Class 1 0 kbps&lt;BR /&gt;Class 2 16590 kbps&lt;BR /&gt;Class 3 35469 kbps&lt;BR /&gt;Class 4 309 kbps&lt;BR /&gt;Class 5 51859 kbps&lt;BR /&gt;Class 6 13692 kbps&lt;BR /&gt;Class 7 424 kbps&lt;BR /&gt;Class 8 0 kbps&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Using the above results as a template I created the API call as follows (and this does work in a web browser):&lt;/P&gt;&lt;P&gt;https://PAN-FW-url/api/?type=op&amp;amp;cmd=&amp;lt;show&amp;gt;&amp;lt;qos&amp;gt;&amp;lt;interface&amp;gt;&amp;lt;entry name='ethernet1/2'&amp;gt;&amp;lt;throughput&amp;gt;0&amp;lt;/throughput&amp;gt;&amp;lt;/entry&amp;gt;&amp;lt;/interface&amp;gt;&amp;lt;/qos&amp;gt;&amp;lt;/show&amp;gt;&amp;amp;key=APIkey&lt;/P&gt;&lt;P&gt;Here's the results I get:&lt;/P&gt;&lt;P&gt;&amp;lt;?xml version="1.0"?&amp;gt;&lt;BR /&gt;-&amp;lt;response status="success"&amp;gt;&lt;BR /&gt;&amp;lt;result&amp;gt;Class 1 0 kbps Class 2 61035 kbps Class 3 15621 kbps Class 4 2435 kbps Class 5 7329 kbps Class 6 1693 kbps Class 7 3592 kbps Class 8 0 kbps &amp;lt;/result&amp;gt;&lt;BR /&gt;&amp;lt;/response&amp;gt;&lt;/P&gt;&lt;P&gt;Here's a snippet from the powershell script (the two Uri's are for comparison):&lt;/P&gt;&lt;P&gt;$Uri1 = "https://PAN-FW-url/api/?type=op&amp;amp;cmd=&amp;lt;show&amp;gt;&amp;lt;qos&amp;gt;&amp;lt;interface&amp;gt;&amp;lt;entry name='ethernet1/2'&amp;gt;&amp;lt;throughput&amp;gt;0&amp;lt;/throughput&amp;gt;&amp;lt;/entry&amp;gt;&amp;lt;/interface&amp;gt;&amp;lt;/qos&amp;gt;&amp;lt;/show&amp;amp;key=APIkey"&lt;BR /&gt;$Uri2 = "https://PAN-FW-url/api/?type=op&amp;amp;cmd=&amp;lt;show&amp;gt;&amp;lt;clock&amp;gt;&amp;lt;/clock&amp;gt;&amp;lt;/show&amp;gt;&amp;amp;key=APIkey"&lt;/P&gt;&lt;P&gt;$Results = Invoke-WebRequest -Method Get -Uri $Uri1&lt;/P&gt;&lt;P&gt;this one fails with:&lt;/P&gt;&lt;P&gt;Invoke-WebRequest : Illegal parameter [request]&lt;BR /&gt;At C:\Program Files (x86)\PAN QoS download traffic.ps1:57 char:12&lt;BR /&gt;+ $Results = Invoke-WebRequest -Method Get -Uri $Uri1&lt;BR /&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt;+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException&lt;BR /&gt;+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I've confirm that my basic script is functional by running the second Uri which runs and returns the system time with no issues:&lt;/P&gt;&lt;P&gt;$Results = Invoke-WebRequest -Method Get -Uri $Uri2&lt;/P&gt;&lt;P&gt;The thing that stands out different between the two Uri's as a possible illegal parameter is the &amp;lt;entry name='ethernet1/2'&amp;gt; section, other than that the two are similar in form and function.&lt;/P&gt;&lt;P&gt;So my thinking is it's somehow a syntax error in powershell or the firewall is somehow handling both differently.&lt;/P&gt;&lt;P&gt;I've exhausted the website information and can't seem to find the correct answer so I'm hoping you can help!&lt;/P&gt;&lt;P&gt;Can you suggest the appropriate syntax for powershell for this call or point me in the right direction?&lt;/P&gt;&lt;P&gt;Thanks!&lt;BR /&gt;Stan...&lt;/P&gt;</description>
    <pubDate>Wed, 11 Dec 2019 13:37:46 GMT</pubDate>
    <dc:creator>StanG</dc:creator>
    <dc:date>2019-12-11T13:37:46Z</dc:date>
    <item>
      <title>API Powershell script fails with specific Invoke-WebRequest call</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/api-powershell-script-fails-with-specific-invoke-webrequest-call/m-p/303192#M2091</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to create a restful api call against our firewall to map historical QoS Statistics on a certain interface.&lt;/P&gt;&lt;P&gt;I've seemed to come across an issue that's not working and I was hoping you could help.&lt;/P&gt;&lt;P&gt;First question first: the information that I'm trying to get is the QoS Statistics (Network -&amp;gt; QoS -&amp;gt; Statistics)&lt;/P&gt;&lt;P&gt;Has that been exposed by SNMP in any recent PANos versions?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;if not here's my issue:&lt;/P&gt;&lt;P&gt;Here's the command I'm trying to use to retrieve information in the API call: show qos interface ethernet1/2 throughput 0&lt;/P&gt;&lt;P&gt;I've verify the syntax to use running the following commands on the FW console:&lt;/P&gt;&lt;P&gt;debug cli on&lt;BR /&gt;show qos interface ethernet1/2 throughput 0&lt;/P&gt;&lt;P&gt;I get:&lt;/P&gt;&lt;P&gt;(container-tag: qos container-tag: interface container-tag: entry key-tag: name value: ethernet1/2 leaf-tag: throughput value: 0 pop-tag: pop-tag:)&lt;BR /&gt;((eol-matched: . #t) (context-inserted-at-end-p: . #f))&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;lt;request cmd="op" cookie="05...34" uid="502"&amp;gt;&amp;lt;operations&amp;gt;&amp;lt;show&amp;gt;&amp;lt;qos&amp;gt;&lt;BR /&gt;&amp;lt;interface&amp;gt;&amp;lt;entry name='ethernet1/2'&amp;gt;&amp;lt;throughput&amp;gt;0&amp;lt;/throughput&amp;gt;&amp;lt;/entry&amp;gt;&amp;lt;/interface&amp;gt;&lt;BR /&gt;&amp;lt;/qos&amp;gt;&amp;lt;/show&amp;gt;&amp;lt;/operations&amp;gt;&amp;lt;/request&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;2019-12-10 15:15:27&lt;BR /&gt;&amp;lt;response status="success"&amp;gt;&amp;lt;result&amp;gt;&amp;lt;![CDATA[Class 1 0 kbps&lt;BR /&gt;Class 2 16590 kbps&lt;BR /&gt;Class 3 35469 kbps&lt;BR /&gt;Class 4 309 kbps&lt;BR /&gt;Class 5 51859 kbps&lt;BR /&gt;Class 6 13692 kbps&lt;BR /&gt;Class 7 424 kbps&lt;BR /&gt;Class 8 0 kbps&lt;BR /&gt;]]&amp;gt;&amp;lt;/result&amp;gt;&amp;lt;/response&amp;gt;&lt;/P&gt;&lt;P&gt;Class 1 0 kbps&lt;BR /&gt;Class 2 16590 kbps&lt;BR /&gt;Class 3 35469 kbps&lt;BR /&gt;Class 4 309 kbps&lt;BR /&gt;Class 5 51859 kbps&lt;BR /&gt;Class 6 13692 kbps&lt;BR /&gt;Class 7 424 kbps&lt;BR /&gt;Class 8 0 kbps&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Using the above results as a template I created the API call as follows (and this does work in a web browser):&lt;/P&gt;&lt;P&gt;https://PAN-FW-url/api/?type=op&amp;amp;cmd=&amp;lt;show&amp;gt;&amp;lt;qos&amp;gt;&amp;lt;interface&amp;gt;&amp;lt;entry name='ethernet1/2'&amp;gt;&amp;lt;throughput&amp;gt;0&amp;lt;/throughput&amp;gt;&amp;lt;/entry&amp;gt;&amp;lt;/interface&amp;gt;&amp;lt;/qos&amp;gt;&amp;lt;/show&amp;gt;&amp;amp;key=APIkey&lt;/P&gt;&lt;P&gt;Here's the results I get:&lt;/P&gt;&lt;P&gt;&amp;lt;?xml version="1.0"?&amp;gt;&lt;BR /&gt;-&amp;lt;response status="success"&amp;gt;&lt;BR /&gt;&amp;lt;result&amp;gt;Class 1 0 kbps Class 2 61035 kbps Class 3 15621 kbps Class 4 2435 kbps Class 5 7329 kbps Class 6 1693 kbps Class 7 3592 kbps Class 8 0 kbps &amp;lt;/result&amp;gt;&lt;BR /&gt;&amp;lt;/response&amp;gt;&lt;/P&gt;&lt;P&gt;Here's a snippet from the powershell script (the two Uri's are for comparison):&lt;/P&gt;&lt;P&gt;$Uri1 = "https://PAN-FW-url/api/?type=op&amp;amp;cmd=&amp;lt;show&amp;gt;&amp;lt;qos&amp;gt;&amp;lt;interface&amp;gt;&amp;lt;entry name='ethernet1/2'&amp;gt;&amp;lt;throughput&amp;gt;0&amp;lt;/throughput&amp;gt;&amp;lt;/entry&amp;gt;&amp;lt;/interface&amp;gt;&amp;lt;/qos&amp;gt;&amp;lt;/show&amp;amp;key=APIkey"&lt;BR /&gt;$Uri2 = "https://PAN-FW-url/api/?type=op&amp;amp;cmd=&amp;lt;show&amp;gt;&amp;lt;clock&amp;gt;&amp;lt;/clock&amp;gt;&amp;lt;/show&amp;gt;&amp;amp;key=APIkey"&lt;/P&gt;&lt;P&gt;$Results = Invoke-WebRequest -Method Get -Uri $Uri1&lt;/P&gt;&lt;P&gt;this one fails with:&lt;/P&gt;&lt;P&gt;Invoke-WebRequest : Illegal parameter [request]&lt;BR /&gt;At C:\Program Files (x86)\PAN QoS download traffic.ps1:57 char:12&lt;BR /&gt;+ $Results = Invoke-WebRequest -Method Get -Uri $Uri1&lt;BR /&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt;+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException&lt;BR /&gt;+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I've confirm that my basic script is functional by running the second Uri which runs and returns the system time with no issues:&lt;/P&gt;&lt;P&gt;$Results = Invoke-WebRequest -Method Get -Uri $Uri2&lt;/P&gt;&lt;P&gt;The thing that stands out different between the two Uri's as a possible illegal parameter is the &amp;lt;entry name='ethernet1/2'&amp;gt; section, other than that the two are similar in form and function.&lt;/P&gt;&lt;P&gt;So my thinking is it's somehow a syntax error in powershell or the firewall is somehow handling both differently.&lt;/P&gt;&lt;P&gt;I've exhausted the website information and can't seem to find the correct answer so I'm hoping you can help!&lt;/P&gt;&lt;P&gt;Can you suggest the appropriate syntax for powershell for this call or point me in the right direction?&lt;/P&gt;&lt;P&gt;Thanks!&lt;BR /&gt;Stan...&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 13:37:46 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/api-powershell-script-fails-with-specific-invoke-webrequest-call/m-p/303192#M2091</guid>
      <dc:creator>StanG</dc:creator>
      <dc:date>2019-12-11T13:37:46Z</dc:date>
    </item>
  </channel>
</rss>

