// this is usually handled by an azure function public async Task <string> Post(TopicDetectionRequest request) { var content = new StringContent(JsonConvert.SerializeObject(request), System.Text.Encoding.UTF8, "application/json"); var result = await _httpClient.PostAsync($"{serviceEndpoint}topics", content).ConfigureAwait(false); var resultLocation = result.Headers.GetValues("Location").First(); return(resultLocation); }
public static TopicDetectionRequest CreateRequest(IEnumerable <Article> articles) { var request = new TopicDetectionRequest() { Documents = new List <Document>(), StopWords = new List <string>(), StopPhrases = new List <string>() }; foreach (var article in articles) { request.Documents.Add(new Document() { Id = article.Id.ToString(), Text = article.Title + "\n" + article.Description }); } return(request); }