Enhanced Security Measures in Place:   To ensure a safer experience, we’ve implemented additional, temporary security measures for all users.

API to create Address Group

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements

API to create Address Group

L1 Bithead

I am trying to create a new address group using API but I always end up getting

 

<response status="error" code="12">

<msg>
<line>
Invalid target object in set handler
</line>
</msg>

</response>

 

Can someone help me with the correct xpath to create a new shared address group empty or with a list of address objects.

6 REPLIES 6

L4 Transporter

If you're using PAN-OS 9.0, I recommend the new REST API. You don't need XPaths to create Address Groups with the new REST API:

  https://docs.paloaltonetworks.com/pan-os/9-0/pan-os-panorama-api.html#

 

If you're using python, you might consider leveraging the Device Framework library. Here's an example of how to create an Address Object.

  https://pandevice.readthedocs.io/en/latest/usage.html#configuration

 

Address Groups are very similar:

  https://pandevice.readthedocs.io/en/latest/module-objects.html#pandevice.objects.AddressGroup

 

If you're using GoLang, we also have the PanGo library:

  https://github.com/PaloAltoNetworks/pango

 

If you're not using Python or Go, you can check out this XML API tutorial lab:

  http://api-lab.paloaltonetworks.com/set-edit-object.html

 

It uses pan-python library, but you don't need python code to use it.  There are several examples of creating Address Objects and Address Groups with XPaths and XML.

 

Hope that helps!

 -Brian

 

 

Hey Brian,

 

Thanks for the reply. I have been trying to use https://docs.paloaltonetworks.com/pan-os/9-0/pan-os-panorama-api.html#.

 

I am using JAVA to create address Groups and rules. And this doesnt work -

 

https://<firewall>/api/?key=apikey&type=config&action=set&key=keyvalue&xpath=xpath-value&element=element-value 

where the xpath-value is:

/config/devices/entry/vsys/entry/rulebase/security/rules/entry[@name='rule1']

I am able create address objects using xpath = /config/shared/address/entry[@name='hostname'] and body/ element as element=<ip-netmask>"+ip+"</ip-netmask>.

 

But a similar one above doesnt work for address groups.

 

Also in

/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/address-group

 

what is supposed to be the devices entry name and vsys entry name?

I keep getting

<response status="error" code="13">
<msg>
<line>Could not find schema node for xpath /config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='device-group-name']/address-group</line>
</msg>
</response>

L1 Bithead

Hi, 

 

see tool I've shared which can do this for you.

 

Cheers,

 

Simon

Do the operation in CLI first with the "debug cli on" command activated. This will give you the precise path you need for the API call.

 

See https://docs.paloaltonetworks.com/pan-os/8-0/pan-os-panorama-api/get-started-with-the-pan-os-xml-api...

L2 Linker

There are two types of address groups in the Palo Alto Networks firewalls; dynamic and static. By default, the firewall creates a static address group if you do not explicitly select dynamic. Therefore, you need to add the static element at the time of address group creation. The example below shows an example of creating an address-group named "test-address-group"

 

[https://<firewall-ip>/api/?type=config&action=set&xpath=/config/devices/entry[@name='localhost.localdomain']/vsys/entry[@name='vsys1']/address-group/entry[@name='test-address-group']&element=<static />&key=<yourfirewall-ip-key>]

 

Hope this explains the mystery.

  • 14744 Views
  • 6 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!