internal async Task <BacktraceResult> SendAsync(Guid requestId, string json, List <string> attachments, BacktraceReport report, int deduplication = 0) { string contentType = FormDataHelper.GetContentTypeWithBoundary(requestId); string boundary = FormDataHelper.GetBoundary(requestId); using (var content = new MultipartFormDataContent(boundary)) { var requestUrl = _serverurl.ToString(); if (deduplication > 0) { requestUrl += $"&_mod_duplicate={deduplication}"; } var request = new HttpRequestMessage(HttpMethod.Post, requestUrl); content.AddJson("upload_file.json", json); content.AddFiles(attachments); //// clear and add content type with boundary tag content.Headers.Remove("Content-Type"); content.Headers.TryAddWithoutValidation("Content-Type", contentType); request.Content = content; try { using (var response = await HttpClient.SendAsync(request)) { var fullResponse = await response.Content.ReadAsStringAsync(); if (response.StatusCode != HttpStatusCode.OK) { var err = new WebException(response.ReasonPhrase); System.Diagnostics.Trace.WriteLine(fullResponse); OnServerError?.Invoke(err); return(BacktraceResult.OnError(report, err)); } var result = JsonConvert.DeserializeObject <BacktraceResult>(fullResponse); result.BacktraceReport = report; OnServerResponse?.Invoke(result); return(result); } } catch (Exception exception) { System.Diagnostics.Trace.WriteLine($"Backtrace - Server error: {exception.ToString()}"); OnServerError?.Invoke(exception); return(BacktraceResult.OnError(report, exception)); } } }