Пример #1
0
        private async Task <JObject> Exec()
        {
            Dictionary <string, object> headers = GetHeader(_Headers);

            Dictionary <String, object> headerAll = new Dictionary <string, object>();
            Dictionary <string, object> mainJson  = new Dictionary <string, object>();

            //Dictionary<string, object> urlQueries = new Dictionary<string, object>();

            if (headers != null && headers.Count() > 0)
            {
                foreach (var header in headers)
                {
                    headerAll.Add(header.Key, (String)header.Value);
                }
            }

            mainJson.Add("environment", this.Stack.Config.Environment);

            foreach (var kvp in UrlQueries)
            {
                mainJson.Add(kvp.Key, kvp.Value);
            }
            try
            {
                HttpRequestHandler RequestHandler = new HttpRequestHandler();
                var outputResult = await RequestHandler.ProcessRequest(_Url, headers, mainJson);

                return(JObject.Parse(ContentstackConvert.ToString(outputResult, "{}")));
            }
            catch (Exception ex)
            {
                throw GetContentstackError(ex);
            }
        }
Пример #2
0
        public async Task <Asset> Fetch()
        {
            Dictionary <String, Object> headers = GetHeader(_Headers);

            Dictionary <String, object> headerAll = new Dictionary <string, object>();
            Dictionary <string, object> mainJson  = new Dictionary <string, object>();

            //Dictionary<string, object> urlQueries = new Dictionary<string, object>();

            if (headers != null && headers.Count() > 0)
            {
                foreach (KeyValuePair <string, object> header in headers)
                {
                    headerAll.Add(header.Key, (String)header.Value);
                }
            }
            mainJson.Add("environment", this.StackInstance.Config.Environment);

            foreach (var kvp in UrlQueries)
            {
                mainJson.Add(kvp.Key, kvp.Value);
            }
            try
            {
                HttpRequestHandler RequestHandler = new HttpRequestHandler();
                var outputResult = await RequestHandler.ProcessRequest(_Url, headers, mainJson);

                JObject obj = JObject.Parse(ContentstackConvert.ToString(outputResult, "{}"));
                return(obj.SelectToken("$.asset").ToObject <Asset>(this.StackInstance.Serializer));
            }
            catch (Exception ex)
            {
                throw GetContentstackError(ex);
            }
        }