Hi Folks,
Reviewing the Open Messaging API documentation , about The maximum size of all the custom attributes' key strings and value strings together (not including quotes, commas, or braces used in JSON representation) in one message must be less than 2KB.
However, when performing tests using the code below to limit the size to the maximum allowed (2KB), the API responds that the size is greater than 2048 bytes.
function checkCustomAttributesSize(customAttributes) {
let totalSize = 0;
// We recurse each key/value pair in customAttributes
for (const [key, value] of Object.entries(customAttributes)) {
// Sum the key size
totalSize += Buffer.byteLength(key, 'utf8');
// Sum the size of the value (convert to string if necessary)
totalSize += Buffer.byteLength(String(value), 'utf8');
}
}
I would like to receive instructions on how to calculate the maximum size allowed (2KB) in the open messaging API, in order to limit the sending of custom attributes to what is allowed by the API and avoid failures.
Attached are two examples, one in which the API accepts the message and one in which the API returns that the size has been exceeded.
However, both examples do not have a size greater than 2KB adding the key and value in utf8.
Thx advanced
Járlei
sample_nok.json (2.0 KB)
sample_ok.json (2.0 KB)