Data Action - REST POST 413

Trying to POST a variable containing a long string - a transcript - to a notes endpoint via a data action. It’s failing with a 413 Payload Too Large error.

The data action is simple enough:

{
 "dataAction": {
 "parameters": {
 "body": "{{flow.variable.transcript}}",
 "contentType": "application/json"
 },
 "mimeType": "application/json"
 }
}

The transcript variable holds a string ~16KB in size. I’ve checked the docs - nothing about a hard limit on note length or request size for that endpoint. Just a hunch, but it feels like something’s getting truncated before it even hits the API. We’ve seen this before with variables exceeding 8KB, but usually the error is a 400.

Workaround currently is chunking the transcript and posting multiple notes. Not ideal.

1 Like

That payload’s too big - yeah.

{ “dataAction”: { “parameters”: { “body”: “{{flow.variable.transcript}}”, “contentType”: “application/json” }, “mimeType”: “application/json” } }

The notes endpoint has a 4KB limit - it’s in teh docs - somewhere. You’re sendin’ 16KB. It won’t work. You’ll get a 413 every time.

Try chunkin’ the transcript. Split it into 4KB segments and POST each one seperately. You’ll need to modify the flow to loop, obviously.

Here’s a basic example of how to split it - this is just the string part, you’ll need to build it into a data action loop:

function chunkString(str, size) {
 const chunkArray = [];
 for (let i = 0; i < str.length; i += size) {
 chunkArray.push(str.substring(i, i + size));
 }
 return chunkArray;
}

const transcript = "{{flow.variable.transcript}}";
const chunkedTranscript = chunkString(transcript, 4000); // 4KB chunks

Then, in your flow, iterate through chunkedTranscript and POST each chunk to the notes endpoint.

fwiw, we hit this same issue with call recordings last year. Took like 2 hrs to figure out the 4KB limit wasn’t documented very well.

W.

1 Like

Right, payload size limits - always a fun one. We had this exact issue back in late '21 with the pre-chat form data, trying to stuff everything into a user field.

The notes endpoint’s limit is indeed 4KB - it’s not documented super clearly, but you’ll hit a 413 consistently above that. Chunking’s one way, but it’s messy. What we ended up doing was base64 encoding the transcript → POST the encoded string → decode on the other side. It shaved off like 30-40% of the string size.

Here’s a data action config that’ll do the encode. You’ll need a corresponding decode step in the flow, obviously.

{
 "dataAction": {
 "parameters": {
 "body": "{{flow.variable.transcript | base64_encode}}",
 "contentType": "application/json"
 },
 "mimeType": "application/json"
 }
}

Took like 2 hrs to get the base64 decode bit right on the receiving end - kept getting padding errors. Turns out, the SDK’s base64 decode function is a little picky. Also, watch out for character sets - encoding/decoding can sometimes mangle unicode. Encoding the string before it hits the variable might be cleaner, depending on where the transcript’s coming from.

Base64 encoding the transcript worked - got it down to ~11KB. 413 is gone. We’re on Genesys Cloud, so didn’t want to mess with looping data actions if a simple encode/decode would do.

2 Likes

The 413 error - it acts like a keyboard trap in the API flow. Perhaps the request parser is blocking the large payload.

Base64 encoding is a good way - yes - but perhaps the notes endpoint isn’t the best place for 16KB of transcript. Not 100% sure but - is there a different data object where you can store the full transcript? Something designed for larger text blocks?

If you must use the notes endpoint - can you check the keyboard focus order? Sometimes the notes object’s UI is not fully accessible when the data is very long. A screen reader user may not be able to move through the content easily.

Another idea - and fwiw - is to use the Interaction object. You can add custom metadata to the Interaction. The limit on that is much higher than the notes endpoint. Here is an example - how you add metadata:

{
 "customData": {
 "transcript": "{{flow.variable.transcript}}"
 }
}

You’d need to adapt the flow to set the customData object when the interaction completes. Then you can retrieve it from the Interaction record.

Do you have a need to display the full transcript in the notes field? Or is it just for storage? Knowing that may help determine the best approach.