예제 #1
0
        private void PostJsonRequest(string url, WebhooksRequest forwardRequest, HttpRequestCallback callback, object userState = null, bool callAsync = false)
        {
            var stream = new MemoryStream();
            var json   = JsonConvert.SerializeObject(forwardRequest, new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore,
                TypeNameHandling  = TypeNameHandling.None,
            });
            var data = Encoding.UTF8.GetBytes(json);

            stream.Write(data, 0, data.Length);

            var request = new HttpRequest
            {
                Url           = url,
                Method        = "POST",
                Accept        = "application/json",
                ContentType   = "application/json",
                Callback      = callback,
                UserState     = userState,
                CustomHeaders = this.customHttpHeaders,
                DataStream    = stream,
                Async         = callAsync
            };

            this.PluginHost.LogDebug(string.Format("PostJsonRequest: {0} - {1}", url, json));

            this.PluginHost.HttpRequest(request);
        }
예제 #2
0
        private void PostJsonRequest(string url, WebhooksRequest forwardRequest, HttpRequestCallback callback, object userState = null, bool callAsync = false)
        {
            var stream = new MemoryStream();
            var json = JsonConvert.SerializeObject(forwardRequest, new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore,
                TypeNameHandling = TypeNameHandling.None,
            });
            var data = Encoding.UTF8.GetBytes(json);
            stream.Write(data, 0, data.Length);

            var request = new HttpRequest
            {
                Url = url,
                Method = "POST",
                Accept = "application/json",
                ContentType = "application/json",
                Callback = callback,
                UserState = userState,
                CustomHeaders = this.customHttpHeaders,
                DataStream = stream,
                Async = callAsync
            };

            this.PluginHost.LogDebug(string.Format("PostJsonRequest: {0} - {1}", url, json));

            this.PluginHost.HttpRequest(request);
        }