jarlei | 2024-10-24 19:22:58 UTC | #1
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 | attachment](upload://lcv7fzdpko37mWm3dbMemZyBRNi.json) (2.0 KB) |
[sample_ok.json | attachment](upload://fIgDCemeRZfnwTadrB8IzICQH2N.json) (2.0 KB) |
jarlei | 2024-10-29 13:35:52 UTC | #2
Hi guys any news???
thx
Járlei
Colum_Mullally | 2024-10-30 11:10:54 UTC | #3
Hi Járlei,
So sorry for the delay in response and thank you for the feedback it has been very useful. After looking into your issue. I would have to agree the docs outlined here Open Messaging API documentation are very misleading I will take and action to update them to more accurately reflect the check.
regarding your code snippet it should be as simple as
function checkCustomAttributesSize(customAttributes) { return Buffer.byteLength(JSON.stringify(customAttributes), 'utf8'); }
From my digging into this topic there is a bug which slightly bloats your string value for this check which I hope to fix and rollout to all production regions in the coming weeks.
Hope this finds you well and thank you again for being an active member of our forum, Colum Mullally
smurray_sixbell | 2024-11-07 14:25:59 UTC | #4
Do you know when this solution will be available?
system | 2024-12-08 14:26:41 UTC | #5
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 30058