Support

Expand all | Collapse all

C# Rest API authentication

  • 1.  C# Rest API authentication

    Posted 10 days ago
    I am playing with the C# Rest API example from github and I keep getting a 401 unauthorized message when trying to use my clientID and secret that I generated for my account.  Not really sure what I am doing wrong.  Could anyone point me in the right direction?

    ------------------------------
    Nathan Haynes
    ------------------------------


  • 2.  RE: C# Rest API authentication

    Posted 10 days ago
    Hi,
    have you added SSL Certficate exceptions?





    ------------------------------
    zuafsha sarwari
    SAMSON AG
    ------------------------------



  • 3.  RE: C# Rest API authentication

    Posted 10 days ago
    Yes I tried adding an exception to accept all ssl certificates so I don't think that is the issue.  I think the issue is the credentials I am using aren't being accepted or the example is outdated it looks to be over 3 years old.  Not sure what has changed with the rest api in that time but I would expect the code examples they have provided to work.

    ------------------------------
    Nathan Haynes
    ------------------------------



  • 4.  RE: C# Rest API authentication

    Posted 10 days ago
    Yes i have tried this Example too and it doesnt worked for me too!

    But i have add exceptions for SSL Certificate and Authentificationtype in the Header. It worked thn.

    try this:
    request.PreAuthenticate = true;

    ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

    String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));

    request.Headers.Add("Authorization", "Basic " + encoded);

    ------------------------------
    zuafsha sarwari
    SAMSON AG
    ------------------------------



  • 5.  RE: C# Rest API authentication

    Posted 10 days ago
    That definitely seemed to help (it didn't throw an exception at least now).  Thanks!  I'll play around with it from here and see if I can actually manipulate data now.

    ------------------------------
    Nathan Haynes
    ------------------------------



  • 6.  RE: C# Rest API authentication

    Posted 10 days ago
    Good LUCK!!

    ------------------------------
    zuafsha sarwari
    SAMSON AG
    ------------------------------