0

I'm newbie on A.C API/SDK. I'm looking for solution for connecting my future C# dev. to my ActiveCollab self hosted install.

I finding a API on GitHub:https://github.com/sfarbota/c-sharp-activecollab-feather-sdk But i think the cod it not write for the self Hosted !?

Any body have a samples of code for doing that ?

best thanks for your help.

JB Baron

I'm trying that: in example project, in main fn from programm.cs:

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)
        {...}

But it not working, the debug return error in Post fn from Connector.cs.

jbbaron
  • 1
  • 2

2 Answers2

0

The project already contains an example.

Samks
  • 96
  • 1
  • 10
  • Thanks Samuel,I'm sorry but i don't see – jbbaron Oct 25 '16 at 10:20
  • I finding it in the example on this page:[link(]https://github.com/activecollab/activecollab-feather-sdk). but I don't know the way to using it in the c# SDK example. – jbbaron Oct 25 '16 at 10:25
0

You have to issue a token and use it as key

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

Also, you have to make some minor changes in the source code in order to make it work.

//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() }
}));
adrian
  • 151
  • 1
  • 1
  • 5