Code written for calling message statistics-
SentEmailPayload payload = new SentEmailPayload()
{
ManagerRootId = "{xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx}",
PageIndex = 0,
PageSize = 100,
Search = "",
Sorting = "dendDate",
Type = "{xxxxxx-xxxx-xxxx-xxxx-xxxxxx}"
};
result = Sitecore.Context.User.Name;
var url = "https://host_name/sitecore/api/ssc/exm/MessageStatistics";
var request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/json";
request.CookieContainer = cookies; // cookie after login api being called
var requestBody = JsonConvert.SerializeObject(payload);
var data = new UTF8Encoding().GetBytes(requestBody);
using (var dataStream = request.GetRequestStream())
{
dataStream.Write(data, 0, data.Length);
}
var response = (HttpWebResponse)request.GetResponse();
For this above code, I keep getting 401
unauthorized in the last line. Can anyone help me with this?
Thanks, Sai