Example #1
0
        private BacktraceResult Send(Guid requestId, string json, List <string> attachments, BacktraceReport report, int deduplication = 0)
        {
            var requestUrl = _serverurl.ToString();

            if (deduplication > 0)
            {
                requestUrl += $"&_mod_duplicate={deduplication}";
            }

            var    formData    = FormDataHelper.GetFormData(json, attachments, requestId);
            string contentType = FormDataHelper.GetContentTypeWithBoundary(requestId);
            var    request     = WebRequest.Create(requestUrl) as HttpWebRequest;

            //Set up the request properties.
            request.Method        = "POST";
            request.ContentType   = contentType;
            request.ContentLength = formData.Length;
            try
            {
                using (Stream requestStream = request.GetRequestStream())
                {
                    requestStream.Write(formData, 0, formData.Length);
                    requestStream.Close();
                }
                return(ReadServerResponse(request, report));
            }
            catch (Exception exception)
            {
                OnServerError?.Invoke(exception);
                return(BacktraceResult.OnError(report, exception));
            }
#endif
        }