paulb

Acquiring the Authentication Token

0 votes
I'm trying to get the Authentication token with the following code, however its return error "The remote server returned an error: (405) Method Not Allowed." string url = "https://sandbox.esignlive.com/api/authenticationTokens"; string apiKey = "WXNKRk9vb*****************"; using (var client = new WebClient()) { var uri = new Uri(url); var encoding = new UTF8Encoding(); client.Headers.Add("Content-Type", "application/json"); client.Headers.Add("Accept", "application/json"); client.Headers.Add("Authorization", "Basic " + apiKey); string response = encoding.GetString(client.DownloadData(uri)); }

Reply to: Acquiring the Authentication Token

0 votes
When making POST requests using WebClient, you should try to do it this way:
using (var client = new WebClient())
            {
            byte[] response =
       client.UploadValues("https://sandbox.esignlive.com/api/authenticationTokens", new NameValueCollection()
       {
           { "Content-Type", "application/json" },
           { "Accept", "application/json" },
           { "Authorization", "Basic " + apiKey}
       });
            string result = System.Text.Encoding.UTF8.GetString(response);
            Debug.WriteLine("Result: " + result);
            }
Hope it helps!
Haris Haidary OneSpan Technical Consultant

Reply to: Acquiring the Authentication Token

0 votes
Works a charm. Thank you!

Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off