Using API with cURL

MadDemonoide

New member
Joined
Jun 14, 2021
Messages
5
Hi all,

For some reason whenever I try to connect to the API with cURL, it get this response. What am I doing wrong?

I tried these methods of calling the API with cURL:

The url's and api keys have been edited for security reasons

curl --request POST --user 'user:xxxxxxxxxxxxxxxxxxxxx' --data 'domain=domain.nl&action=add&type=A&name=apitest.domain.nl&value=127.0.0.1' https://mydirectadminurl.tld:2222/CMD_API_DNS_CONTROL

curl -s --max-time 15 --user 'user:xxxxxxxxxxxxxxxxxxxxx' "https://mydirectadminurl.tld:2222/C...type=A&name=apitest.domain.nl&value=127.0.0.1"

Both calls respond with this:

HTML:
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8;"/>
        <meta name="viewport" content="width=device-width, initial-scale=1"/>


        <title>
            mydirectadminurl.tld | Login
        </title>
        <link rel="shortcut icon" href="/images/favicon.png" type="image/x-icon" />
        <meta name="robots" content="noindex,nofollow" />
        <script>
            var tokens = {
                LOST_PASSWORD: "no" === "yes",
                TIME: {
                    current: 1623697219 * 1000,
                    offset: 86400 * 1000,
                },
                AUTH_METHOD: "CMD_LOGIN",
                QUESTION: "|QUESTION_JSON|",
                LOGIN_LANGUAGES: "default=en;en=English;",
                GEO_IP_LANG: "|GEO_IP_LANG|",
                trial: "|IS_TRIAL_LICENSE|",
            };
        </script>
    <link href="/assets/css/login.css" rel="stylesheet"></head>
    <body>
        <div id="login"></div>
    <script type="text/javascript" src="/assets/login.js"></script></body>

Am I doing something wrong, and do you know where?

Thank you!
 
Hi. Thank you. Yes, we have a Standard license on this server.
I just used the webpage to create the cURL command, but I receive the same response.
 
Could maybe try to use the domain that the panel is assigned to (The one in your license.) instead of a domain that is on the panel itself?
 
Edit: Fixed that part..
Used the wrong api point (should use CMD_API_DNS_ADMIN)

It works now. :)
 
Last edited:
When using CMD_API_DNS_CONTROL you must choose correct authentication because only specific user can use this whereas if you use CMD_API_DNS_ADMIN, it can be used by admin to control all domains (best to use this if authentication is admin). So, I think the main problem there was the authentication selection to use with API.

You can actually can see the more deep error messages by putting directadmin into debug mode like this: https://forum.directadmin.com/threads/api-command-to-enforce-ssl.64152/#post-334227
 
Back
Top