api call to add a domain to the blacklist

Jun 17, 2022
30
1
8
Hi,
can anyone give me an api call sample to add a domain like "spam.tld" to the global blacklist?
WebUI = Mail Filter - Who Objects - Blacklist - Add - Domain - Domain: "spam.tld" (OK)
thanks in advance
 
Thanks but add a domain does not work.

/api2/json/config/ruledb/who
gives me the ID 2
{"data":[{"id":2,"info":"Global blacklist","name":"Blacklist"},{"name":"Whitelist","info":"Global whitelist","id":3}]}

/api2/json/config/ruledb/who/2/domain=spam.tld
returns {"data":null}
and nothings is added to the blacklist.
 
I try it with postman but it does not work.
Code:
POST : https://mail.domain.tld:8006/api2/extjs/config/ruledb/who/2/domain?domain=tukame.org.tr
Body: {"username":"root", "password":"pmgSecretPassWord"}
Result:
Code:
401 No Ticket
when i try to get a ticket
Code:
POST : https://mail.domain.tld:8006/api2/extjs/access/ticket
Body: {"username":"root", "password":"pmgSecretPassWord"}
Result:
Code:
{
    "message": "authentication failure\n",
    "data": null,
    "success": 0,
    "status": 401
}
 
Last edited:
im a little bit forward:
Code:
Body: {"username":"root", "password":"pmgSecretPassWord", "realm":"pmg"}
Result:
Code:
{
    "data": {
        "ticket": "PMG:root@pam:656729E5::flUxFmFk1nHLdZH/jTjw11cmPmZknqi1TueT79xNW+cv4HiXPlx9NY4vlyhOKqZiM5H3usyPP+GMX0JmsE42QL9xBAYeIg/0sESeO7H/UnfjLEaDXnOapT43ZDQGK5FooE+MT+IBfScbs3OsKEVtA//AA9mIwdU4dM1vFth4HUa4+/JHGd71ss02+X2a7Eigni9aAptd29kqPlW+IJhyyuZOwgpUFV9zXQ/VG1E0suZA1UwNTzsAko3Lo6PSDEtkIxUV/zMdqpQMte3ItEXL2f3CJ9u5DZ76BPnTlHV/neY1auTFeFwYde0GbP8MWRzVnt2aUTXc0Drs8Ngvl60glw==",
        "role": "root",
        "CSRFPreventionToken": "656729E5:E3pdeNrn8syJLno2PdTpshqlg8rns6upA6kCy6Zu+WE",
        "username": "root@pam"
    },
    "success": 1
}
I try
Code:
POST https://mail.domain.tld:8006/api2/extjs/config/ruledb/who/2/domain?domain=tukame.org.tr
{"ticket": "PMG:root@pam:656729E5::flUxFmFk1nHLdZH/jTjw11cmPmZknqi1TueT79xNW+cv4HiXPlx9NY4vlyhOKqZiM5H3usyPP+GMX0JmsE42QL9xBAYeIg/0sESeO7H/UnfjLEaDXnOapT43ZDQGK5FooE+MT+IBfScbs3OsKEVtA//AA9mIwdU4dM1vFth4HUa4+/JHGd71ss02+X2a7Eigni9aAptd29kqPlW+IJhyyuZOwgpUFV9zXQ/VG1E0suZA1UwNTzsAko3Lo6PSDEtkIxUV/zMdqpQMte3ItEXL2f3CJ9u5DZ76BPnTlHV/neY1auTFeFwYde0GbP8MWRzVnt2aUTXc0Drs8Ngvl60glw==","domain":"tukame.org.tr"}
Result:
Code:
401 No ticket
 
generally the pmg api behaves similarly to the pve api, so see here: https://pve.proxmox.com/wiki/Proxmox_VE_API

note that the ticket must be provided as a cookie named 'PMGAuthCookie', and for POST/PUT requests you need also to provide the CSRFPreventionToken as a header
 

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!