• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Issue REST API Plesk Unauthorized

whyicantgetin

New Pleskian
Hi,

I have issue on REST API Plesk, I already configure on panel.ini to enable API

Like this
[api]
enabled=on

For API keys I use this command: plesk bin secret_key -c -ip-address 203.0.xxx.xx

curl -k -X POST -H "X-API-Key: <API KEYS>" -H "Content-Type: application/json" -H "Accept: application/json" "https://<IP>:8443/api/v2/cli/mail/call" -d '{ "params": ["--create", "<EMAIL>, "-passwd", "<PSD>", "-mailbox", "true"]}'

I get unauthorized message when using cURL online. On Command Prompt, I got "curl: option -mailbox,: expected a proper numerical parameter" message...


I try run https://58.185.xxx.xxx:8443/api/v2/swagger.yml and get the data..

Can you help me? I want to create mail account with REST API.

Thank you
 
Last edited by a moderator:
Successfully tried with this method:

Code:
# curl -k -X POST --user admin:"XXXXX" -H "Content-Type: application/json" -H "Accept: application/json" -d"{}" "https://xxxxx-sites.plesk.space:8443/api/v2/auth/keys"
{
    "key": "f811322d-b8c0-ff5c-035c-cbbb6dd5xxx"
}You have new mail in /var/spool/mail/root



Code:
# curl -k -X POST -H "X-API-Key: f811322d-b8c0-ff5c-035c-cbbb6dd5xxx" -H "Content-Type: application/json" -H "Accept: application/json" "https://xxxxx-sites.plesk.space:8443/api/v2/cli/mail/call" -d '{ "params": ["--create", "[email protected]", "-passwd", "XXXXX", "-mailbox", "true"]}'
{
    "code": 0,
    "stdout": "SUCCESS: Creation of mailname '[email protected]' complete",
    "stderr": ""
 
For
Code:
# curl -k -X POST --user admin:"XXXXX" -H "Content-Type: application/json" -H "Accept: application/json" -d"{}" "https://xxxxx-sites.plesk.space:8443/api/v2/auth/keys"

I run command 
[CODE]# plesk bin secret_key -c -ip-address <IP>
, isn't it same thing to get API keys? Right now I have account admin but not name admin


For
[CODE]# curl -k -X POST -H "X-API-Key: f811322d-b8c0-ff5c-035c-cbbb6dd5xxx" -H "Content-Type: application/json" -H "Accept: application/json" "https://xxxxx-sites.plesk.space:8443/api/v2/cli/mail/call" -d '{ "params": ["--create", "[email protected]", "-passwd", "XXXXX", "-mailbox", "true"]}'


Can I know where you test this ? I still get Unauthorized on web and "curl: option -mailbox,: expected a proper numerical parameter" on RDP...
 
I didn't have Linux... Is there any way/method that create Mail Account using REST API ? I need to create signing up email
 
I try this

curl -k -X POST -H "X-API-Key: <KEY>" “https://<IP>:8443/api/v2/cli/mail/call” -H “accept: application/json” -H “Content-Type: application/json” -d ‘{ “params”: [ “–help” ]}’

Result :
Invalid category provided, here is a list of all categories:

auth Different types of authentication methods
connection Low level networking operations
curl The command line tool itself
dns General DNS options
file FILE protocol options
ftp FTP protocol options
http HTTP and HTTPS protocol options
imap IMAP protocol options
misc Options that don't fit into any other category
output Filesystem output
pop3 POP3 protocol options
post HTTP Post specific options
proxy All options related to proxies
scp SCP protocol options
sftp SFTP protocol options
smtp SMTP protocol options
ssh SSH protocol options
telnet TELNET protocol options
tftp TFTP protocol options
tls All TLS/SSL related options
upload All options for uploads
verbose Options related to any kind of command line output of curl

Is mail not include on REST API anyomore ?
 
Back
Top