Getting 400 Bad Request when trying to create security policy rule

Reply
L0 Member

Getting 400 Bad Request when trying to create security policy rule

I'm trying to create a security policy rule using the REST API but I keep getting an empty response with 400 status.

 

URL:

 

https://<PANORAMA_IP>/restapi/9.0/Policies/SecurityPreRules

Headers:

Content-Type: application/json
X-PAN-KEY: <KEY>

 

 

 

{
	"entry": [{
		"target": {
			"devices": [{
				"@name": "001801020796",
				"vsys": {
					"entry": [{
						"@name": "vsys5"
					}]
				}
			}]
		},
		"source": {
			"member": ["1.1.1.1"]
		},
		"destination": {
			"member": ["2.2.2.2"]
		},
		"service": {
			"member": ["TCP_18207"]
		},
		"action": "allow",
		"@name": "new-rule-1",
		"@location": "device-group",
		"@device-group": "ST_DG1.1.1.1",
		"to": {
			"member": ["any"]
		},
		"from": {
			"member": ["any"]
		},
		"application": {
			"member": ["any"]
		}
	}]
}

 

 

 

I also tried adding ?location=device-group&device-group=ST_DG1.1.1.1 to the URL but it did not make any change.

 

I'm getting back an empty response with status code 400. I tried to find it in https://<PANORAMA_IP>/debug but it wasn't logged.

 

My end goal is to create a policy rule that contains a specific vsys of a specific firewall as "target". I'm using the panos Python library and for now there seems to be a bug with this functionality (https://github.com/PaloAltoNetworks/pan-os-python/issues/273) so I resorted to making direct API calls.

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 Live Community as a whole!

The Live Community thanks you for your participation!