I'm getting Error 401 not authenticated, when I try deleting a session. I got no problems logging in (i.e posting) and getting the latest session. My problem is when destroying it. Here's my code:
string result = ""
try
{
Uri url = new Uri("https://<host>/rest/auth/1/session");
var webRequest = (HttpWebRequest)WebRequest.Create(url);
var userpass = "<email>:<password>";
var credentials = Convert.ToBase64String(Encoding.Default.GetBytes(userpass));
webRequest.Method = "DELETE";
webRequest.Accept = "application/json";
webRequest.Headers.Add("Authorization", "Basic " + credentials);
using (var wr = (HttpWebResponse)webRequest.GetResponse())
{
using (var sr = new StreamReader(wr.GetResponseStream()))
{
result = sr.ReadToEnd();
}
}
}
catch(Exception ex)
{
result = ex.Message;
}
return result;
I tried "auth/latest/session", Encoding.UTF8, Encoding.ASCII, but no luck.Appreciate any help! Thanks!