Example #1
0
        static void DisplayResponseData(AnalyzeResultResponse responseData)
        {
            if (responseData != null)
            {
                var fields    = responseData.analyzeResult.documentResults.First().fields;
                var fieldDict = fields.GetType()
                                .GetProperties(BindingFlags.Instance | BindingFlags.Public)
                                .ToDictionary(prop => prop.Name, prop => prop.GetValue(fields, null));

                Console.WriteLine("Display data: ");

                foreach (var kvp in fieldDict)
                {
                    FormatOutput(kvp.Key, kvp.Value as FieldBase);
                }
            }
            else
            {
                Console.WriteLine("No data found");
            }
        }
Example #2
0
        static async Task <AnalyzeResultResponse> GetAnalyzeFormResult(string locationUri)
        {
            var client      = new HttpClient();
            var queryString = HttpUtility.ParseQueryString(string.Empty);

            // Request headers
            client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", SUBSCRIPTION_KEY);

            //var uri = "https://japaneast.api.cognitive.microsoft.com/formrecognizer/v2.0-preview/custom/models/{modelId}/analyzeResults/{resultId}?" + queryString;

            var response = await client.GetAsync(locationUri);

            AnalyzeResultResponse resultData = null;

            if (response.IsSuccessStatusCode)
            {
                var contentString = await response.Content.ReadAsStringAsync();

                resultData = JsonConvert.DeserializeObject <AnalyzeResultResponse>(contentString);
            }

            return(resultData);
        }