public SubmissionResponse PostUserDescription(string referenceId, UserDescription description, ExceptionlessConfiguration config, IJsonSerializer serializer) {
            if (!config.IsValid)
                return new SubmissionResponse(500, message: "Invalid client configuration settings.");

            string data = serializer.Serialize(description);
            string url = String.Format("{0}/events/by-ref/{1}/user-description", GetServiceEndPoint(config), referenceId);

            HttpResponseMessage response;
            try {
                HttpContent content = new StringContent(data, Encoding.UTF8, "application/json");

                // don't compress data smaller than 4kb
                if (data.Length > 1024 * 4)
                    content = new GzipContent(content);

                _client.Value.AddAuthorizationHeader(config.ApiKey);
                response = _client.Value.PostAsync(url, content).ConfigureAwait(false).GetAwaiter().GetResult();
            } catch (Exception ex) {
                return new SubmissionResponse(500, message: ex.Message);
            }

            int settingsVersion;
            if (Int32.TryParse(GetSettingsVersionHeader(response.Headers), out settingsVersion))
                SettingsManager.CheckVersion(settingsVersion, config);

            return new SubmissionResponse((int)response.StatusCode, GetResponseMessage(response));
        }
Beispiel #2
0
        public SubmissionResponse PostUserDescription(string referenceId, UserDescription description, ExceptionlessConfiguration config, IJsonSerializer serializer)
        {
            if (!config.IsValid)
            {
                return(SubmissionResponse.InvalidClientConfig500);
            }

            string data = serializer.Serialize(description);
            string url  = $"{GetServiceEndPoint(config)}/events/by-ref/{referenceId}/user-description";

            HttpResponseMessage response;

            try {
                HttpContent content = new StringContent(data, Encoding.UTF8, "application/json");

                // don't compress data smaller than 4kb
                if (data.Length > 1024 * 4)
                {
                    content = new GzipContent(content);
                }

                _client.Value.AddAuthorizationHeader(config.ApiKey);
                response = _client.Value.PostAsync(url, content).ConfigureAwait(false).GetAwaiter().GetResult();
            } catch (Exception ex) {
                return(new SubmissionResponse(500, exception: ex));
            }

            if (Int32.TryParse(GetSettingsVersionHeader(response.Headers), out int settingsVersion))
            {
                SettingsManager.CheckVersion(settingsVersion, config);
            }

            var message = GetResponseMessage(response);

            if ((int)response.StatusCode == 200 && "OK".Equals(message, StringComparison.OrdinalIgnoreCase))
            {
                return(SubmissionResponse.Ok200);
            }

            return(new SubmissionResponse((int)response.StatusCode, message));
        }
Beispiel #3
0
        public SubmissionResponse PostUserDescription(string referenceId, UserDescription description, ExceptionlessConfiguration config, IJsonSerializer serializer)
        {
            if (!config.IsValid)
            {
                return(new SubmissionResponse(500, message: "Invalid client configuration settings."));
            }

            string data = serializer.Serialize(description);
            string url  = String.Format("{0}/events/by-ref/{1}/user-description", GetServiceEndPoint(config), referenceId);

            HttpResponseMessage response;

            try {
                HttpContent content = new StringContent(data, Encoding.UTF8, "application/json");

                // don't compress data smaller than 4kb
                if (data.Length > 1024 * 4)
                {
                    content = new GzipContent(content);
                }

                _client.Value.AddAuthorizationHeader(config.ApiKey);
                response = _client.Value.PostAsync(url, content).ConfigureAwait(false).GetAwaiter().GetResult();
            } catch (Exception ex) {
                return(new SubmissionResponse(500, exception: ex));
            }

            int settingsVersion;

            if (Int32.TryParse(GetSettingsVersionHeader(response.Headers), out settingsVersion))
            {
                SettingsManager.CheckVersion(settingsVersion, config);
            }

            return(new SubmissionResponse((int)response.StatusCode, GetResponseMessage(response)));
        }