Пример #1
0
        public async Task <string> SendRequestWithNoBodyContentAsync(AuthenticationApiModel authentication, string methodNameAndParameters)
        {
            hp.DefaultRequestHeaders.Clear();
            hp.DefaultRequestHeaders.TryAddWithoutValidation(ApiConstants.AUTHENTICATION_HEADER, authentication.UserEmail + ";" + authentication.Key);
            HttpContent         hc = new StringContent(string.Empty, Encoding.Unicode, "application/json");
            HttpResponseMessage httpResponseMessage = await hp.PostAsync(endpointUrl + methodNameAndParameters, hc);

            return(await httpResponseMessage.Content.ReadAsStringAsync());
        }
Пример #2
0
        public async Task <string> SendRequestAsync(AuthenticationApiModel authentication, string methodName, byte[] body)
        {
            hp.DefaultRequestHeaders.Clear();
            hp.DefaultRequestHeaders.TryAddWithoutValidation(ApiConstants.AUTHENTICATION_HEADER, authentication.UserEmail + ";" + authentication.Key);
            HttpContent         hc   = new ByteArrayContent(body);
            HttpResponseMessage task = await hp.PostAsync(endpointUrl + methodName, hc);

            return(await task.Content.ReadAsStringAsync());
        }
Пример #3
0
        public string SendRequest(AuthenticationApiModel authentication, string methodName, byte[] content)
        {
            hp.DefaultRequestHeaders.Clear();
            hp.DefaultRequestHeaders.TryAddWithoutValidation(ApiConstants.AUTHENTICATION_HEADER, authentication.UserEmail + ";" + authentication.Key);
            HttpContent         hc = new ByteArrayContent(content);
            HttpResponseMessage httpResponseMessage = hp.PostAsync(endpointUrl + methodName, hc).Result;
            string response = httpResponseMessage.Content.ReadAsStringAsync().Result;

            return(response);
        }
Пример #4
0
        public string SendRequest(AuthenticationApiModel authentication, string methodName, string jsonBodyObject)
        {
            hp.DefaultRequestHeaders.Clear();
            hp.DefaultRequestHeaders.TryAddWithoutValidation(ApiConstants.AUTHENTICATION_HEADER, authentication.UserEmail + ";" + authentication.Key);
            HttpContent         hc = new StringContent(jsonBodyObject, Encoding.Unicode, "application/json");
            HttpResponseMessage httpResponseMessage = hp.PostAsync(endpointUrl + methodName, hc).Result;
            string response = httpResponseMessage.Content.ReadAsStringAsync().Result;

            return(response);
        }