Panorama rest-api edit security policy post rule - 400 Unexpected here

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

Panorama rest-api edit security policy post rule - 400 Unexpected here

L0 Member

Hi!

 

I'm writing a python script to change the security profile for any security policy rule that is using that profile (very tedious to manually click through hundreds of policys via GUI). Panorama rest-api is always throwing a 400 response to me:


URL query parameters and response:

location=device-group&device-group=firewall-fw&name=rule-test

{"code":3,"message":"Invalid Object","details":[{"@type":"CauseInfo","causes":[{"code":12,"module":"panui_mgmt","description":"Invalid Object: rule-test -> destination: unexpected here."}]}]}
400

 Json-template:

    "entry": [
{
"@location": "device-group",
"@device-group": policy.vsys,
"@name": policy.name,
"from": {
"member": policy.fromzone
},
"to": {
"member": policy.tozone
},
"source": {
"member": policy.source
},
"destination": {
"member": policy.destination
},
"service": {
"member": policy.service
},
"application": {
"member": policy.application
},
"action": policy.action,
}
]
}


 Any tips would be appreciated! 

3 REPLIES 3

L6 Presenter

Try debugging it :

 

HTTP Request Methods and Status Codes (paloaltonetworks.com)

 

PAN-OS REST API Request and Response Structure (paloaltonetworks.com)

 

How to Run a PAN-OS Web UI Debug - Knowledge Base - Palo Alto Networks

 

 

But I think you have errors in what you have written so see the example here as for example the device group in query and the the json body does not match etc.

 

Work with Policy Rules on Panorama (REST API) (paloaltonetworks.com)

 

curl -X PUT \ 'http://10.1.1.7/restapi/9.0/Policies/SecurityPreRules?LOCATION=device-group&device-group=devicegroup...' \ -H 'X-PAN-KEY: LUFRPT=' \ -d '{ "entry": [ { "@device-group": "devicegroup-7", "@location": "device-group", "@name": "allow-dns", "action": "allow", "application": { "member": [ "dns" ] },

I'll try debugging it, thanks for the links!

 

"But I think you have errors in what you have written so see the example here as for example the device group in query and the the json body does not match etc."

I should hade clarified that I'm also using pan-os-python (pan-os-python.readthedocs.io), I'm using the class SecurityRule to get all security rules from a firewall. The variables in my json-body are parameters from the SecurityRule class:

policy.vsys, policy.source, policy.destination

 

You may also test using Ansible as it is generally more tested in my view:

 

 

Palo Alto Networks and Ansible

 

 

Solved: LIVEcommunity - updating a portion of the rule - ansible - LIVEcommunity - 318575 (paloalton...

  • 2666 Views
  • 3 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!