I have been using below code to post crash/Exception report to HockeyApp (Internal Server Error) ?

vasuvasu INMember ✭✭

using (HttpClient client = new HttpClient())
{
string log = "Exception thrown from here";
client.DefaultRequestHeaders.Add("X-HockeyAppToken", "xxxxxxxxxxxxxxxxxxxxxxxxxx");

            client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("*/*"));

            var content = new MultipartFormDataContent();
            var contentTypeString = content.Headers.ContentType.ToString().Replace("\"", "");
            content.Headers.Remove("Content-Type");
            content.Headers.TryAddWithoutValidation("Content-Type", contentTypeString);

            var stringContent = new StringContent(log);
            stringContent.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("text/plain");

            content.Add(stringContent, "log", "crash.log");

            var response = await client.PostAsync("https://rink.hockeyapp.net/api/2/apps/[APP_ID]/crashes/upload", content); 

}

Sign In or Register to comment.