<?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: Panorama PowerShell RESTAPI Error in Panorama Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/panorama-discussions/panorama-powershell-restapi-error/m-p/1224851#M2824</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/890649287"&gt;@JonButterfield&lt;/a&gt; ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The specific error you are getting is "Invalid Body" which means the URL is correct, but the JSON is not formatted correctly, e.g. bad syntax or parameter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I like to test the URL, header, and body separately from code in order to verify I have the syntax and parameters correct before coding.&amp;nbsp; A good tool for this testing is Postman.&amp;nbsp; &lt;A href="https://www.postman.com/" target="_blank" rel="noopener"&gt;https://www.postman.com/&lt;/A&gt;&amp;nbsp; It is free and has Windows, Mac, and Linux clients.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could print the JSON body to the CLI to verify the syntax.&amp;nbsp; I don't know PowerShell hash tables very well.&amp;nbsp; Is the [pscustomobject] supposed to be [ordered]?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At 1st glance, the syntax appears to be correct.&amp;nbsp; &lt;A href="https://docs.paloaltonetworks.com/pan-os/11-1/pan-os-panorama-api/get-started-with-the-pan-os-rest-api/work-with-address-objects-rest-api" target="_blank"&gt;https://docs.paloaltonetworks.com/pan-os/11-1/pan-os-panorama-api/get-started-with-the-pan-os-rest-api/work-with-address-objects-rest-api&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 27 Mar 2025 04:22:12 GMT</pubDate>
    <dc:creator>TomYoung</dc:creator>
    <dc:date>2025-03-27T04:22:12Z</dc:date>
    <item>
      <title>Panorama PowerShell RESTAPI Error</title>
      <link>https://live.paloaltonetworks.com/t5/panorama-discussions/panorama-powershell-restapi-error/m-p/1224839#M2823</link>
      <description>&lt;P&gt;Good morning,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I am attempting to streamline some massive object uploads into the Panorama after PowerShell massages the data first. I am running into an issue getting my GET / POST functions to work correctly when making the calls and was hoping someone would have some advice here.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;I am running the below command to attempt the Push to add a test object and am receiving the error pasted after:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;$response = Invoke-RestMethod -Method Post -Header $xkey -Uri $panoFQDNURL -Body $customObject -ContentType 'application/json'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The error received is "Invoke-RestMethod : {"code":3,"message":"Invalid Body","details":[{"@type":"CauseInfo","causes":[{"code":9,"module":"pan_api","description":"Invalid Body"}]}]}"&lt;BR /&gt;&lt;BR /&gt;I have attempted multiple ways of formatting the $customObject data to no avail. I feel I am missing something small and am just overlooking it after digging through a bunch of forum posts here and the documentation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is the current method I have utilized for creating the $customObject:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;$configobject = [pscustomobject]@{&lt;BR /&gt;'@location' = $location&lt;BR /&gt;'device-group' = $devicegroup&lt;BR /&gt;'@name' = $name&lt;BR /&gt;'description' = $description&lt;BR /&gt;'fqdn' = $fqdn&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;$customObject = ConvertTo-Json $configobject&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The @location is being defined as 'device-group' and I have verified the device group, fqdn, description and name variables populate correctly. I have attempt using Invoke-WebRequest as well with the same result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The url I have is below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://x.x.x.x/restapi/vX/Objects/Addresses?location=device-group&amp;amp;device-group=XXX&amp;amp;name=FQDNNAME" target="_blank"&gt;https://x.x.x.x/restapi/vX/Objects/Addresses?location=device-group&amp;amp;device-group=XXX&amp;amp;name=FQDNNAME&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have verified the variable produces the correct IP address, version, device-group name, and FQDN Name for the new object.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any API guru's in here have any advice? I am admittedly a novice when it comes to dealing with API calls from PowerShell so I'm hoping this is something simple I'm overlooking. &lt;/P&gt;</description>
      <pubDate>Wed, 26 Mar 2025 18:43:34 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/panorama-discussions/panorama-powershell-restapi-error/m-p/1224839#M2823</guid>
      <dc:creator>JonButterfield</dc:creator>
      <dc:date>2025-03-26T18:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: Panorama PowerShell RESTAPI Error</title>
      <link>https://live.paloaltonetworks.com/t5/panorama-discussions/panorama-powershell-restapi-error/m-p/1224851#M2824</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/890649287"&gt;@JonButterfield&lt;/a&gt; ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The specific error you are getting is "Invalid Body" which means the URL is correct, but the JSON is not formatted correctly, e.g. bad syntax or parameter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I like to test the URL, header, and body separately from code in order to verify I have the syntax and parameters correct before coding.&amp;nbsp; A good tool for this testing is Postman.&amp;nbsp; &lt;A href="https://www.postman.com/" target="_blank" rel="noopener"&gt;https://www.postman.com/&lt;/A&gt;&amp;nbsp; It is free and has Windows, Mac, and Linux clients.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could print the JSON body to the CLI to verify the syntax.&amp;nbsp; I don't know PowerShell hash tables very well.&amp;nbsp; Is the [pscustomobject] supposed to be [ordered]?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At 1st glance, the syntax appears to be correct.&amp;nbsp; &lt;A href="https://docs.paloaltonetworks.com/pan-os/11-1/pan-os-panorama-api/get-started-with-the-pan-os-rest-api/work-with-address-objects-rest-api" target="_blank"&gt;https://docs.paloaltonetworks.com/pan-os/11-1/pan-os-panorama-api/get-started-with-the-pan-os-rest-api/work-with-address-objects-rest-api&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2025 04:22:12 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/panorama-discussions/panorama-powershell-restapi-error/m-p/1224851#M2824</guid>
      <dc:creator>TomYoung</dc:creator>
      <dc:date>2025-03-27T04:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: Panorama PowerShell RESTAPI Error</title>
      <link>https://live.paloaltonetworks.com/t5/panorama-discussions/panorama-powershell-restapi-error/m-p/1224874#M2825</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/890649287"&gt;@JonButterfield&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Source of info : &lt;A href="https://your_panorama/restapi-doc/" target="_blank" rel="noopener"&gt;https://your_panorama/restapi-doc/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The body is supposed to contain the entry you want to send.&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;{
  "entry": {
// here if the object is an ip-netmask type
    "ip-netmask": "string",
    "tag": {
      "member": [
        "string"
      ],
// in the restapi-doc, it seems @name is required too
    "@name": "name"
    }
  }
}&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;$configobject&amp;nbsp;is mean to be in the query parameter.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/77347"&gt;@TomYoung&lt;/a&gt;&amp;nbsp;+1 for the postman option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Olivier&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2025 03:56:38 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/panorama-discussions/panorama-powershell-restapi-error/m-p/1224874#M2825</guid>
      <dc:creator>ozheng</dc:creator>
      <dc:date>2025-03-27T03:56:38Z</dc:date>
    </item>
  </channel>
</rss>

