예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="token"></param>
        /// <param name="clave"></param>
        /// <returns>response ws json</returns>
        public static async Task <string> getRecepcion(OAuth2Token token, string clave)
        {
            HttpResponseMessage responseMessage;

            using (HttpClient httpClient = new HttpClient())
            {
                httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.access_token);
                HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, URLServices.RECEPCION_GET_CLAVE(clave));
                responseMessage = await httpClient.SendAsync(request);
            }

            return(await responseMessage.Content.ReadAsStringAsync());
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="token"></param>
        /// <param name="jsonData"></param>
        /// <returns></returns>
        public static async Task <string> postRecepcion(OAuth2Token token, string jsonData)
        {
            HttpResponseMessage responseMessage;

            using (HttpClient httpClient = new HttpClient())
            {
                httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.access_token);

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

                responseMessage = await httpClient.PostAsync(URLServices.RECEPCION_POST(), content);

                string x = await responseMessage.Content.ReadAsStringAsync();

                if (responseMessage.IsSuccessStatusCode)
                {
                    return("Success");
                }
                else
                {
                    return("Error");
                }
            }
        }