Is the textract service usable via Rest API?
If so what are the exact parameters to provide on the REST request?
And what are the exact parameters to provide in the elaboration of the canonical request.
For my part I tried the following code:
request_HTTP is restRequest
request_HTTP..URL = URLEncode("https://textract.eu-west-3.amazonaws.com")
request_HTTP..Method = httpPost
request_HTTP.ContentType = "application/x-amz-json-1.1"
request_HTTP.Content = {
"Document":
{
"Bytes":"xxxxx"
}
}
xxxx is the binary buffer of a file = Hash(NameFile.jpg)
requete_HTTP..Header["authorization"] = AWS4-HMAC-SHA256 Credential=myAWSAccessKey/20220411/eu-west-3/textract/aws4_request,SignedHeaders=content-type;host;x-amz-date,Signature=55fbb067c5ea5612146f7252b341fa22473338b6703cf1ad6703cf1
request_HTTP..Header["x-amz-algorithm"] = "AWS4-HMAC-SHA256"
request_HTTP..Header["x-amz-credential"] =myAWSAccessKey/20220411T093952Z/eu-west-3/textract/aws4_request
request_HTTP..Header["x-amz-date"] = "20220411T093952Z"
requete_HTTP..Header["x-amz-target"] = "Text.AnalyzeExpense"
for the canonical request allowing to create the chain to be signed the following code:
POST\n/\nAction=AnalyzeExpense\ncontent-Type:application/x-amz-json-1.1; charset=utf-8\nhost:textract.amazonaws.com\nx-amz-date:20220411T122110Z\ncontent-type;host;x-amz-date\nbufHash_RequestPayload
or bufHash_RequestPayload=LowerCase(Hex(Hash NameFile.jpg))=
14a085e370add4de92a3509c7891c27c9373b37b5ba83c3e395a8570303658c3
In the end I have the answer:
"__type":"InvalidSignatureException",
"message":"The request signature we calculated does not match the signature you provided
I certainly forgot something
in advance thank you for your help
nb: x-amzn-RequestId: 7877cc30-b196-40dd-8e3d-ba6c9dcf6200