Exemple #1
0
            public string GetResponseString(AnalyzeCommentRequest request)
            {
                var content  = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json");
                var response = Client.PostAsync(BaseAddress, content).Result;

                response.EnsureSuccessStatusCode();
                return(response.Content.ReadAsStringAsync().Result);
            }
Exemple #2
0
            public AnalyzeCommentResponse QueryToxicity(string input)
            {
                var requestedAttributeses = new Dictionary <string, RequestedAttributes> {
                    { "TOXICITY", new RequestedAttributes() }
                };
                var req = new AnalyzeCommentRequest(input, requestedAttributeses);
                var res = SendRequest(req);

                return(res);
            }
 public AnalyzeCommentResponse sendRequest(AnalyzeCommentRequest request)
 {
     using (var client = new HttpClient())
     {
         var content  = new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json");
         var response = client.PostAsync(URL, content).Result;
         response.EnsureSuccessStatusCode();
         var data   = response.Content.ReadAsStringAsync().Result;
         var result = JsonConvert.DeserializeObject <AnalyzeCommentResponse>(data);
         return(result);
     }
 }