- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
07-14-2016 02:03 PM
Trying to automate a task of configuring the management interface of a firewall device through the API. I see where the API's leading for the configuration, but I'm stumped as to how to edit/set the IP.
Example. using Powershell:
$Firewall = https://firewall
$apiKey = apikey
$ipaddress = x.x.x.x
$content1 = Invoke-RestMethod "$Firewall/api/?type=config&key=$apiKey&action=set&xpath=/config/devices/entry[@name='localhost.localdomain']/deviceconfig/system/ip-address/member[@name='$ipaddress']"
How would I proceed with setting the $ipaddress I need to the location?
07-17-2016 05:16 PM
The XPath cannot end in slash. For example:
$ ./panxapi.py -t p30443 -xS '<ip-address>192.168.1.102</ip-address>' "/config/devices/entry[@name='localhost.localdomain']/deviceconfig/system/"
set: error [code="13"]: "set failed, may need to override template object first"
<response code="13" status="error"><msg><line>set failed, may need to override template object first</line></msg></response>
$ ./panxapi.py -t p30443 -xS '<ip-address>192.168.1.102</ip-address>' "/config/devices/entry[@name='localhost.localdomain']/deviceconfig/system"
set: success [code="20"]: "command succeeded"
<response code="20" status="success"><msg>command succeeded</msg></response>
07-14-2016 11:32 PM
I think you need to include the "element=" for the value you want to set:
For example somehting like this:
$content1 = Invoke-RestMethod "$Firewall/api/?type=config&key=$apiKey&action=set&xpath=/config/devices/entry[@name='localhost.localdomain']/deviceconfig/system/&element=<ip-address>$ipaddress</ip-address>"
07-15-2016 06:15 AM
I've played around with the element approach from both /deviceconfig/system and /deviceconfig/system/ipaddress.
Unfortunately, I'm not having any luck on it.
07-17-2016 05:16 PM
The XPath cannot end in slash. For example:
$ ./panxapi.py -t p30443 -xS '<ip-address>192.168.1.102</ip-address>' "/config/devices/entry[@name='localhost.localdomain']/deviceconfig/system/"
set: error [code="13"]: "set failed, may need to override template object first"
<response code="13" status="error"><msg><line>set failed, may need to override template object first</line></msg></response>
$ ./panxapi.py -t p30443 -xS '<ip-address>192.168.1.102</ip-address>' "/config/devices/entry[@name='localhost.localdomain']/deviceconfig/system"
set: success [code="20"]: "command succeeded"
<response code="20" status="success"><msg>command succeeded</msg></response>
07-20-2016 01:14 PM
That was it. Thanks ksteves1
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!