[SOLVED] Help deleting pvefw rule using digest through api2

Svintoo

New Member
Oct 17, 2016
2
0
1
44
I'm trying to delete a firewall rule through the API by sending the digest with the HTTP Delete request. But I get an error saying: Unexpected content for method 'DELETE'

The digest can be used in a delete according to the docs to prevent modifying the firewall rules if they've been changed by someone else. This is good IMO since a change in the firewall rules mean that the positions of the rules may change and you risk deleting the wrong rule.
http://pve.proxmox.com/pve-docs/api-viewer/index.html
nodes -> {node} -> lxc -> {vmid} -> firewall -> rules -> {pos} -> DELETE

The parameters node, vmid and pos are part of the API URL. The digest is sent as: application/x-www-form-urlencoded

I'm suspecting that either the docs are wrong or that there is a bug in PVE. This is because:
1) the docs mentions that pos is an optional parameter which it's not since its part of the URL.
2) the source code shows it only allows HTTP POST and HTTP PUT requests to include application/x-www-form-urlencoded. See https://github.com/proxmox/pve-manager/blob/master/PVE/HTTPServer.pm#L1266

My question: Is it possible to delete a firewall rule through the API and include a digest in the delete request?
Or is there any other way to prevent a delete if the firewall rules has been changed?
 
My question: Is it possible to delete a firewall rule through the API and include a digest in the delete request?

Simply encode the digest inside the URI (like with get request):

DELETE /api2/extjs/nodes/{node}/lxc/{vmid}/firewall/rules/{pos}?digest={digest}
 
I had no idea the API supported parameters in the URI.
Thank you! It works great!

I would've change the subject of this thread to "[SOLVED]" but for some reason I can't figure out how.
 
Hi,

DELETE /api2/json/nodes/{node}/qemu/{vmid}/firewall/ipset/{name}

as: /api2/json/nodes/n1/qemu/100firewall/ipset/ipfilter-net0

with

Code:
$params = array(
            'name' => 'ipfilter-net0',
            'node' => 'n1',
            'vmid' => '100',
            'force' => true
        );

leads to:

501 Unexpected content for method 'DELETE'


-----------

Trying using URI call like mentioned here with ?force=true leads to:

Code:
400 Parameter verification failed.` errors\":{\"force\":\"property is not defined in schema and the schema does not allow additional properties

-----------

Sending DELETE /api2/json/nodes/{node}/qemu/{vmid}/firewall/ipset/{name} without any parameters works. But then there is no force to delete the ipset including existing rules.

-------------

So what would be here the correct syntax to make the proxmox api understand that you want to delete an ipset and all rules in this ipset aswell?

Thank you!
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!