paulb

senderAuthenticationTokens call returns error code 415 Unsupported Media Type

0 votes
I can't seem to get the senderAuthenticationToken. I'm receiving a 415 error code, Unsupported Media Type. Any ideas what I'm doing wrong? PackageId packageId = eslClient.CreatePackage(superDuperPackage); using (var client = new WebClient()) { byte[] response = client.UploadValues("https://sandbox.esignlive.com/api/senderAuthenticationTokens", new System.Collections.Specialized.NameValueCollection() { { "Content-Type", "application/json" }, { "Accept", "application/json" }, { "Authorization", "Basic " + apiKey}, { "packageId", packageId.Id} }); string result = System.Text.Encoding.UTF8.GetString(response); }

Reply to: senderAuthenticationTokens call returns error code 415 Unsupported Media Type

0 votes
I've not used the WebClient to do a POST. I can look into that, but I do know that this works for the same:
string jsonString = "{\"packageId\":\"" + packageId.Id + "\"}";
string url = "https://sandbox.esignlive.com/api/senderAuthenticationTokens";
HttpClient myClient = new HttpClient();
myClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", apiKey);
myClient.DefaultRequestHeaders.Add("Accept", "application/json");
StringContent jsonContent = new StringContent(jsonString, Encoding.UTF8, "application/json");
var response = myClient.PostAsync(url,jsonContent).Result;
Debug.WriteLine(response.Content.ReadAsStringAsync().Result);

- Michael

Director, Partner and Developer Technologies, OneSpan

Facebook - Twitter - LinkedIn


Reply to: senderAuthenticationTokens call returns error code 415 Unsupported Media Type

1 votes
For the WebClient way, here is some code that works:
using (var client = new WebClient())
 {
        client.Headers["Content-Type"] = "application/json";
        client.Headers["Accept"] = "application/json";
        client.Headers["Authorization"] = "Basic " + apiKey;
        string response = client.UploadString("https://sandbox.esignlive.com/api/senderAuthenticationTokens", "{\"packageId\":\"" + packageId.Id + "\"}");
                    
        Debug.WriteLine(response);
}

- Michael

Director, Partner and Developer Technologies, OneSpan

Facebook - Twitter - LinkedIn


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