For a deeper look into our World Check One API, look into:

Overview |  Quickstart |  Documentation |  Downloads

question

Upvotes
Accepted
32 4 6 11

Bytes to be written to the stream exceed the Content-Length bytes size specified.

Hi,

I am getting this error while passing Unicode string, For example when I am screening a name

ÖMER HİRFANOĞLU

I am getting error

"Bytes to be written to the stream exceed the Content-Length bytes size specified."

How I can send this text so that it can screen without any error.

Currently I am using UTF8Encoding

UTF8Encoding encoding = new UTF8Encoding();
byte[] byte1 = encoding.GetBytes(postData);


Here is my code

string postData = "{\"entityType\":\"" + entityType + "\",\"groupId\":\"" + groupId + "\",\"providerTypes\":[\"WATCHLIST\"],\"name\":\"" + screenText + "\"}";
string msg = postData;
var contentLength = msg.Length; UTF8Encoding encoding = new UTF8Encoding();
byte[] byte1 = encoding.GetBytes(postData);

// Assemble the POST request - NOTE every character including spaces have to be EXACT
// for the API server to decode the authorization signature
string dataToSign = "(request-target): post " + gatewayurl + "cases/screeningRequest\n" +
"host: " + gatewayhost + "\n" + // no https only the host name
"date: " + date + "\n" + // GMT date as a string
"content-type: " + "application/json" + "\n" +
"content-length: " + contentLength + "\n" +
msg;

string authorisation = "Signature keyId=\"" + apikey + "\",algorithm=\"hmac-sha256\",headers=\"(request-target) host date content-type content-length\",signature=\"" + hmac + "\"";

world-checkworld-check-oneunicode
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
Accepted
4.5k 4 7 8

hmy-documentscode-v12cwc1postrequestcs.txt@ziad.abourizk,

Thank you for the information.

From the above provided information, it seems that you are using the variable 'byte1' for holding the UTF-8 encoded value. However, you are not calculating the length of this encoded value, which might be the reason for calculation of incorrect contentLength. Can you please try calculating the content length of the UTF-8 converted postData and see the outcome?

contentLength = byte1.length;

I am attaching code example (c#) file to this reply for your reference.

Hope this helps.


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvote
4.5k 4 7 8

@ziad.abourizk,

Thank you for the query.

Can you please confirm us the content length which is being calculated for the request body which you are sending in the POST request?

Also, can you please let us know the programing lanaguage which you are using?

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
32 4 6 11

Hi,

I am using C#.Net.

{"entityType":"ORGANISATION","groupId":"xxx","providerTypes":["WATCHLIST"],"name":"ERMAKSAN GEMİ VE TEKNE YAN SANAYI"}

contentLength : 151

DatatoSign:

(request-target): post /v1/cases/screeningRequest
host: rms-world-check-one-api.thomsonreuters.com
date: Mon, 01 Apr 2019 14:06:05 GMT
content-type: application/json
content-length: 151
{"entityType":"ORGANISATION","groupId":"xxx","providerTypes":["WATCHLIST"],"name":"ERMAKSAN GEMİ VE TEKNE YAN SANAYI"}

authorization:

Signature keyId="xxx",algorithm="hmac-sha256",headers="(request-target) host date content-type content-length",signature="a9BEW7NOlLWs7hpUV26EswbVUjHt/pjo57/Qfkz8Tbw="

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvote
32 4 6 11

Thank you very much. It works.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea