示例#1
0
        private async Task <string> StartExtraction(string inputValue, bool ocrFlag = false, bool textFlag = true, bool metadataFlag = false,
                                                    bool tablesFlag = false, bool singleColumnFlag         = true)
        {
            ExtractPdfRequest   requestBody = new ExtractPdfRequest(APIKey, inputValue, ocrFlag, textFlag, metadataFlag, tablesFlag, singleColumnFlag);
            HttpResponseMessage response    = null;

            try
            {
                response = await Client.PostAsync(Endpoints.PdfExtraction, IndicoRequest.StringContentFromObject(requestBody));

                HTTPMagic.CheckStatus(response);
                string responseBody = await response.Content.ReadAsStringAsync();

                return(JsonConvert.DeserializeObject <JobStartResponse>(responseBody).Results);
            }
            catch (HttpRequestException hre)
            {
                throw new IndicoAPIException(Resources.Application_API_Request_Failure, hre);
            }
            finally
            {
                if (response != null)
                {
                    response.Dispose();
                }
            }
        }
示例#2
0
        public async Task <T> GetResults <T>(string jobId)
        {
            IndicoRequest       requestBody = new IndicoRequest(APIKey);
            HttpResponseMessage response    = null;

            try
            {
                response = await Client.PostAsync(string.Format(Endpoints.JobResult, jobId), IndicoRequest.StringContentFromObject(requestBody));

                HTTPMagic.CheckStatus(response);
                string responseBody = await response.Content.ReadAsStringAsync();

                return(JsonConvert.DeserializeObject <JobResultsResponse <T> >(responseBody).Results);
            }
            catch (HttpRequestException hre)
            {
                throw new IndicoAPIException(Resources.Application_API_Request_Failure, hre);
            }
            finally
            {
                if (response != null)
                {
                    response.Dispose();
                }
            }
        }