【问题标题】:cPanel API - Execution not permitted inside of webmail (api2)cPanel API - webmail (api2) 内不允许执行
【发布时间】:2015-07-01 10:53:48
【问题描述】:

我正在开发一个从移动应用程序管理 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;

通讯类

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;
}

非常感谢任何帮助。

【问题讨论】:

    标签: c# cpanel-xmlapi


    【解决方案1】:

    问题是由于使用了错误的端口造成的。尽管我以为我多次检查了端口,但我确实连接到了 webmail 端口(2087)而不是 cPanel 端口(2083)

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-29
      • 2014-07-23
      • 2016-11-11
      相关资源
      最近更新 更多