0

我是 AC API/SDK 的新手。我正在寻找连接我未来的 C# 开发人员的解决方案。到我的 ActiveCollab 自托管安装。

我在 GitHub 上找到了一个 API:https ://github.com/sfarbota/c-sharp-activecollab-feather-sdk 但我认为它不是为自托管写的鳕鱼!?

任何机构都有这样做的代码示例?

非常感谢您的帮助。

JB男爵

我正在尝试:在示例项目中,在 programm.cs 的 main fn 中:

private static void Main(string[] args)
    {
        //Put the new value
        ConfigurationManager.AppSettings["CloudInstanceID"] = "";
        ConfigurationManager.AppSettings["ApiKey"]="";
        Client.apiVersion = "5"; 

        Client.url = "http://my.AC-SelfHosted.fr/" + ConfigurationManager.AppSettings["CloudInstanceID"];
        Client.key = ConfigurationManager.AppSettings["ApiKey"];
        //i'm trying with IssuToken (like AC SDK)
        Client.IssueToken("myUser@Email-login.com", "My_Pasw", "Client Name", "Vendor Name", false);
        var users = Client.GetJson(Client.Get("users"));
        foreach (KeyValuePair<string, object> user in users)
        {...}

但它不起作用,来自 Connector.cs 的 Post fn 中的调试返回错误。

4

2 回答 2

0

您必须发出令牌并将其用作密钥

private static void Main(string[] args)
{
    Client.url = "https://www.url.com";
    Client.key = Client.IssueToken("email@exampple.com", "PASSWORD", "CLIENT_NAME", "VENDOR_NAME", false);
    var users = Client.GetJson(Client.Get("users"));
    foreach (KeyValuePair<string, object> user in users)
    {
        var userProperties = (Dictionary<string, object>)user.Value;
        Console.WriteLine(userProperties["id"].ToString() + ":\t" + userProperties["email"]);
    }
    Console.ReadLine();
}

此外,您必须对源代码进行一些小的更改才能使其正常工作。

//Client.cs:134
//some keys are missing or mispelled
HttpResponseMessage response = connector.Post(PrepareUrl("issue-token"), null,
PrepareParams(new Dictionary<string, object>() {
    { "username", emailOrUsername },
    { "password", password },
    { "client_name", clientName },
    { "client_vendor", clientVendor },
    { "readOnly", readOnly.ToString() }
}));
于 2019-09-05T16:01:54.873 回答
0

该项目已经包含一个示例。

于 2016-10-24T16:22:51.720 回答