<?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>article Nominated Discussion: Using the REST API to Create a Bunch of Address Objects in General Articles</title>
    <link>https://live.paloaltonetworks.com/t5/general-articles/nominated-discussion-using-the-rest-api-to-create-a-bunch-of/ta-p/1226546</link>
    <description>&lt;P&gt;This Nominated Discussion Article is based on the post "&lt;A id="link_2_5158dada1b65d3_113455" class="page-link lia-link-navigation lia-custom-event" href="https://live.paloaltonetworks.com/t5/general-topics/using-the-rest-api-to-create-a-bunch-of-address-objects/m-p/585793" target="_blank" rel="noopener"&gt;Using the REST API to create a bunch of Address Objects&lt;/A&gt;" by&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/137282"&gt;@DaveFitz&lt;/a&gt;&amp;nbsp; and responded to by &lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/77347"&gt;@TomYoung&lt;/a&gt;&amp;nbsp;. Read on to see the discussion and solution!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="lia-message-template-content-zone"&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;I have to create a large number Address Objects and would like to use the REST API to do so.&amp;nbsp; I've seen a number of examples at adding various things, but I'm running into an issue with these specific shared objects.&amp;nbsp; The all live in a device group called Global.&lt;/P&gt;
&lt;P&gt;If I do a GET, I see that an object will look as follows&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;{"@name":"net-vl730-boise", "@location":"shared", "ip-netmask":"10.21.45.0\/24", "description":"Boise VTC Network"}&lt;/LI-CODE&gt;
&lt;P&gt;Am I correct in assuming that when interacting with an object, a field with a leading&amp;nbsp;@ is a required field?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I basically want to have code that creates ~100 more of these.&amp;nbsp; To that end, I have a code snippet that looks as follows:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;headers = {
  'Content-Type': 'application/json',
  'X-PAN-KEY': api_key
  }
name = "net-vl720-miami"
ip_netmask = "10.22.104.0\/22"
payload = json.dumps({
    "entry":{
        "@location":"shared",
        "@name":"net-vl720-miami",
        "ip-netmask":"10.21.46.0\/24",
        "description":"Miami Voice Network"
        }
    })
url = "https://panorama_ip/restapi/v10.1/Objects/Addresses"
try:
    r1 = requests.request("POST",url, headers=headers, data=payload, verify=False)
except:
    print(r1.text)&lt;/LI-CODE&gt;
&lt;P&gt;When I run the code as is, the response I get is:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;'{"code":3,"message":"Missing Query Parameter: location","details":[{"@type":"CauseInfo","causes":[{"code":7,"module":"pan_api","description":"Missing Query Parameter: location"}]}]}'&lt;/LI-CODE&gt;
&lt;P&gt;If I alter the URL to include the location, as so:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;url = "https://w0t809-pan-mgmt.mitre.org/restapi/v10.1/Objects/Addresses?location=shared"&lt;/LI-CODE&gt;
&lt;P&gt;The description part of the response becomes:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;"description":"Missing Query Parameter: name"&lt;/LI-CODE&gt;
&lt;P&gt;So for starters, I'm not sure what belongs in the URL, and what belongs in the payload, as some of the data seems to be duplicated.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I add the name to the URL:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;url = "https://w0t809-pan-mgmt.mitre.org/restapi/v10.1/Objects/Addresses?location=shared&amp;amp;name=" + name&lt;/LI-CODE&gt;
&lt;P&gt;The response changes to&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;"description":"Invalid Object: Edit breaks config validity."&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;Can anybody share what I'm doing wrong?&amp;nbsp; I'm sure I'm not the first person to attempt this.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is what worked for me in Postman.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;URL = https://{{hostname}}.{{domain}}.com/restapi/v10.2/Objects/Addresses?location=shared&amp;amp;name=Test-1-2-3&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Body = 
{
    "entry": [
        {
            "@location": "shared",
            "@name": "Test-1-2-3",
            "ip-netmask": "10.21.46.0/24",
            "tag": {
                "member": [
                    "API"
                ]
            },
            "description": "Miami Voice Network"
        }
    ]
}&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Response =
{
    "@status": "success",
    "@code": "20",
    "msg": "command succeeded"
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The name needs to be in the URL according to this example:&amp;nbsp; &lt;A href="https://docs.paloaltonetworks.com/pan-os/9-1/pan-os-panorama-api/get-started-with-the-pan-os-rest-api/work-with-address-objects-rest-api" target="_blank" rel="noopener"&gt;https://docs.paloaltonetworks.com/pan-os/9-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;My "API" tag already existed.&amp;nbsp; Here is the newly created object in the Panorama GUI:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TomYoung_0-1715017580446.png" style="width: 1067px;"&gt;&lt;img src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/59534iD264750C555B6850/image-dimensions/1067x96?v=v2" width="1067" height="96" role="button" title="TomYoung_0-1715017580446.png" alt="TomYoung_0-1715017580446.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;</description>
    <pubDate>Tue, 15 Apr 2025 23:27:46 GMT</pubDate>
    <dc:creator>kiwi</dc:creator>
    <dc:date>2025-04-15T23:27:46Z</dc:date>
    <item>
      <title>Nominated Discussion: Using the REST API to Create a Bunch of Address Objects</title>
      <link>https://live.paloaltonetworks.com/t5/general-articles/nominated-discussion-using-the-rest-api-to-create-a-bunch-of/ta-p/1226546</link>
      <description>&lt;P&gt;This Nominated Discussion Article is based on the post "&lt;A id="link_2_5158dada1b65d3_113455" class="page-link lia-link-navigation lia-custom-event" href="https://live.paloaltonetworks.com/t5/general-topics/using-the-rest-api-to-create-a-bunch-of-address-objects/m-p/585793" target="_blank" rel="noopener"&gt;Using the REST API to create a bunch of Address Objects&lt;/A&gt;" by&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/137282"&gt;@DaveFitz&lt;/a&gt;&amp;nbsp; and responded to by &lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/77347"&gt;@TomYoung&lt;/a&gt;&amp;nbsp;. Read on to see the discussion and solution!&lt;/P&gt;</description>
      <pubDate>Tue, 15 Apr 2025 23:27:46 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/general-articles/nominated-discussion-using-the-rest-api-to-create-a-bunch-of/ta-p/1226546</guid>
      <dc:creator>kiwi</dc:creator>
      <dc:date>2025-04-15T23:27:46Z</dc:date>
    </item>
  </channel>
</rss>

