Пример #1
0
        private async Task <ResponseDocument> MakeRequest(string tweetFullText)
        {
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            var uri = "https://westeurope.api.cognitive.microsoft.com/text/analytics/v2.0/sentiment?" + queryString;

            HttpResponseMessage response;

            // Request body
            var requestBody = new RequestRootObject
            {
                Documents = new List <RequestDocument>
                {
                    new RequestDocument
                    {
                        Language = _configuration.Language ?? "en",
                        Id       = "1",
                        Text     = tweetFullText
                    }
                }
            };

            var serializedRequestBody = JsonConvert.SerializeObject(requestBody);
            var byteData = Encoding.UTF8.GetBytes(serializedRequestBody);

            using (var content = new ByteArrayContent(byteData))
            {
                content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                response = await _httpClient.PostAsync(uri, content);
            }

            return(await GetResponseDocument(response));
        }
 public BookingServices(RequestRootObject root, ResRootObject res, string str) :
     base(root, res, str)
 {
 }
Пример #3
0
 public RoomDisplayServices(RequestRootObject root, ResRootObject res, string str) :
     base(root, res, str)
 {
 }
Пример #4
0
 public APIAIService(RequestRootObject root, ResRootObject res, string str)
 {
     this.root = root;
     this.res  = res;
     this.str  = str;
 }