cPanel API - 不允许在 webmail (api2) 内部执行

cPanel API - Execution not permitted inside of webmail (api2)

我正在开发一个从移动应用程序管理 cPanel 帐户的应用程序,但首先我要将概念证明作为一个简单的 windows 表单应用程序。用户应该能够使用他们的用户名和密码进行身份验证。

但是,无论我尝试执行什么操作,我总是会收到以下响应:

<Root>
  <cpanelresult>
    <apiversion>2</apiversion>
    <error>Execution of Email::addpop is not permitted inside of webmail (api2)</error>
    <func>addpop</func>
    <data>
      <reason>Execution of Email::addpop is not permitted inside of webmail (api2)</reason>
      <result>0</result>
    </data>
    <module>Email</module>
  </cpanelresult>
</Root>

我尝试过的每个功能都会出现此错误。 cPanel 帐户具有其功能列表中的所有功能。

我使用下面的代码调用API:

表格

Communication com = new Communication();

string result = com.SendRequest("Email", "addpop",
                "&domain ='apitest.DOMAIN.nl'&email='user'&password='12345luggage'&quota='500'");

txtOutput.Text = result;

通讯class

public string SendRequest(string module, string function, string extra = "")
{
    try
    {
        var httpWebRequest =
            (HttpWebRequest) WebRequest.Create(Settings.Default.Server +
                                                string.Format(
                                                    "/json-api/cpanel?cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module={0}&cpanel_jsonapi_func={1}{2}",
                                                    module, function, extra));
        httpWebRequest.Accept = "*/*";
        httpWebRequest.Method = "GET";

        string credentials = (username + ":" + password).Base64Encode();

        httpWebRequest.Headers.Add("Authorization: Basic " + credentials);

        var httpResponse = (HttpWebResponse) httpWebRequest.GetResponse();



        using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
        {
            string answer = streamReader.ReadToEnd();
            XNode node = JsonConvert.DeserializeXNode(answer, "Root");

            return node.ToString();
        }
    }
    catch (WebException ex)
    {
        switch (ex.Status)
        {
            case WebExceptionStatus.ProtocolError:
                return ((HttpWebResponse) ex.Response).StatusCode.ToString();
            case WebExceptionStatus.NameResolutionFailure:
                return "Could not find specified domain: " +
                        ex.Status.ToString();
        }
    }
    return null;
}

非常感谢任何帮助。

问题是使用了错误的端口引起的。尽管我认为我多次检查了端口,但实际上我确实连接到了网络邮件端口 (2087) 而不是 cPanel 端口 (2083)

只需将连接中的端口修改为 2083 即可解决问题。