regulaforensics / documentreader-web-csharp-client Goto Github PK
View Code? Open in Web Editor NEWRegula Document Reader web API c# client compatible with .NET & .NET Core
Home Page: https://regulaforensics.com
Regula Document Reader web API c# client compatible with .NET & .NET Core
Home Page: https://regulaforensics.com
@AlexSatsukevich need you help. could you, please, provide commands for client generation as in example https://github.com/regulaforensics/DocumentReader-web-java-client/blob/master/dev.md
I am closely following the example/quick start for 'Perform a request' provided in the README, but I am getting the following exception when calling api.Process()
:
Regula.DocumentReader.WebClient.Client.ApiException: Error calling ApiProcess: Error while copying content to a stream.
Note: Full stack trace and assoc. code snippet below.
I am calling this C# code as an Azure Function App and, as I suspect it's pertinent, the code runs well and does not throw any exceptions locally, but throws the above exception when deployed to and run in Azure.
From what I can determine, this exception is being thrown by the Regula Document Reader C# Web Client code (and the content it is failing to convert to a stream is the internalised request body, not any content handled by my code), hence reaching out here for some support.
This is using Regula.DocumentReader.WebClient
version 6.9.2
, installed via from NuGet dotnet package add
.
I am using .NET 8 and running the function app in 'dotnet-isolated' mode if that is of any importance.
Any insights and feedback welcomed.
Full Details -
Code Snippet:
string blobBase64 = blobStream.ConvertToBase64();
// Prepare Regula Client & Request
string? regulaBaseUrl = _config.GetValue<string>("REGULA_BASE_URL");
string? regulaLicenseBase46 = _config.GetValue<string>("REGULA_LICENCE_BASE64");
if (String.IsNullOrWhiteSpace(regulaBaseUrl) || String.IsNullOrWhiteSpace(regulaLicenseBase46))
throw new ApplicationException("Regula configuration is missing or incomplete");
ProcessRequestImage image = new ProcessRequestImage(
new ImageData(blobBase64),
Light.WHITE
);
RecognitionParams recognitionParams = new RecognitionParams()
.WithScenario(Scenario.FULL_PROCESS)
.WithResultTypeOutput(new List<int> {
Result.STATUS,
Result.TEXT,
Result.IMAGES,
Result.DOCUMENT_TYPE
});
RecognitionRequest recognitionRequest = new RecognitionRequest(recognitionParams, image);
DocumentReaderApi api = new DocumentReaderApi(regulaBaseUrl)
.WithLicense(regulaLicenseBase46);
RecognitionResponse response = api.Process(recognitionRequest);
Stack Trace:
Regula.DocumentReader.WebClient.Client.ApiException: Error calling ApiProcess: Error while copying content to a stream.
at Regula.DocumentReader.WebClient.Api.ProcessApi.ApiProcessWithHttpInfo(ProcessRequest processRequest, Dictionary2 headers, String xRequestID) at Regula.DocumentReader.WebClient.Api.ProcessApi.ApiProcess(ProcessRequest processRequest, Dictionary2 headers, String xRequestID)
at Regula.DocumentReader.WebClient.Api.DocumentReaderApi.Process(ProcessRequest processRequest, Dictionary`2 headers, String xRequestID)
at Regula.DocumentReader.WebClient.Api.DocumentReaderApi.Process(ProcessRequest processRequest)
at Vaiie.Intelligence.IdDocumentChecks.ProcessIdDocumentBlob(BlobClient idDocBlobClient, String idDocBlobName, BlobContainerClient resultsContainerClient, TableClient checksTableClient, TableClient regulaTableClient, TableClient billingTableClient, FunctionContext executionContext) in /Users/joe.harvey/Development/intelligence/IdDocumentChecks.cs:line 361
Hi. I want to use a client to recognize document fields and document types in a high-load service. The problem is that the client does not support async calls and it will lock a thread for the request time. Are any plans to implement this feature?
var imageBytes = File.ReadAllBytes("australia_passport.jpg");
var image = new ProcessRequestImage(new ImageData(imageBytes), Light.WHITE);
var requestParams = new RecognitionParams()
.WithScenario(Scenario.FULL_PROCESS)
.WithResultTypeOutput(new List<int> { Result.STATUS, Result.TEXT, Result.IMAGES, Result.DOCUMENT_TYPE });
var request = new RecognitionRequest(requestParams, image);
var api = licenseFromEnv != null
? new DocumentReaderApi(apiBaseUrl).WithLicense(licenseFromEnv)
: new DocumentReaderApi(apiBaseUrl).WithLicense(licenseFromFile);
var response = api.Process(request); // should be available api.ProcessAsync(request)?
В целом клиент на charp больше всего похож на java клиент. Из-застатической типизации, добавить методы в какую-нибудь сгенерируемую модель становится немногосложнее.
https://github.com/regulaforensics/DocumentReader-web-java-client/blob/master/dev.md разработка под java, генератор сейчас стоит брать 5.0.0-beta.2 версии
В целом нужно двигаться примерно так:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.