/// <summary> /// Starts processing a collection for topics asynchronously. /// </summary> /// <param name="request">The request.</param> /// <returns>The URL to check processing status.</returns> public async Task <string> StartTopicProcessingAsync(TopicRequest request) { var reqJson = JsonConvert.SerializeObject(request); byte[] reqData = Encoding.UTF8.GetBytes(reqJson); if (request.MinDocumentsPerWord > 0) { this.Url = string.Format("{0}?minDocumentsPerWord={1}", this.Url, request.MinDocumentsPerWord); if (request.MaxDocumentsPerWord > 0) { this.Url = string.Format("{0}&maxDocumentsPerWord={1}", this.Url, request.MaxDocumentsPerWord); } } else if (request.MaxDocumentsPerWord > 0) { this.Url = string.Format("{0}?maxDocumentsPerWord={1}", this.Url, request.MaxDocumentsPerWord); } HttpWebRequest req = (HttpWebRequest)WebRequest.Create(this.Url); req.Headers.Add("Ocp-Apim-Subscription-Key", this.ApiKey); req.ContentType = "application/json"; req.Accept = "application/json"; req.ContentLength = reqData.Length; req.Method = "POST"; var reqStream = await req.GetRequestStreamAsync(); reqStream.Write(reqData, 0, reqData.Length); reqStream.Close(); var response = await req.GetResponseAsync(); var operationUrl = response.Headers["Operation-Location"]; return(operationUrl); }
/// <summary> /// Starts processing a collection for topics. /// </summary> /// <param name="request">The request.</param> /// <returns>The URL to check processing status.</returns> public string StartTopicProcessing(TopicRequest request) { return(StartTopicProcessingAsync(request).Result); }