Flow Designer - Data Stream - Rejected large REST payload

Justin Scheich
Tera Guru

I am trying to add multiple if conditions to a Datastream for each in my flow.
I have hit a limit after adding 12 if statements.
The error occurs when saving the flow not when trying to run the flow. 

The error in the system logs is
Rejected large REST payload with content-length = 28188007 bytes. Max allowed: 26214400 bytes.

I've already increased the max rest content length system property to 25MB.

According to the documentation for data streams, they're built for response data over 10MB.
Data Stream actions and pagination (servicenow.com)

I do have pagination enabled and the response payload size is only 379811 bytes.

Is there a better way to accomplish this? or resolve the error?

2 REPLIES 2

HrishabhKumar
Kilo Sage

Hi @Justin Scheich ,

Based on your problem, you might want to consider these:

 

  • Optimize If Conditions:

    • Break down the logic into smaller flows or sub-flows.
    • Use lookup tables or switch-case structures.
  • Use Scripted REST APIs:

    • Offload logic to a Scripted REST API to preprocess data and apply conditions before sending it to the flow.

Thanks,

Hope this helps.

If my response proves helpful please mark it helpful and accept it as solution to close this thread.

 

HrishabhKumar
Kilo Sage

Hi @Justin Scheich ,

I'm providing the detail remediation, here:

1. Create Scripted REST API

  1. Navigate to: System Web Services > Scripted REST APIs.

  2. Create API and Endpoint:

 

 

(function process(request, response) {
    var responseData = [];
    var input = request.body.data;

    input.forEach(function(item) {
        if (item.condition1) {
            item.result = 'Condition1 met';
        } else if (item.condition2) {
            item.result = 'Condition2 met';
        }
        responseData.push(item);
    });

    response.setBody(responseData);
})(request, response);

 

 

         

      2. Call REST API from Flow:

  • Use a REST step to call the API.
  • Pass data and handle the response.

 

2. Break Down Flows

  1. Create Sub-Flows:

 

 

// Example Sub-Flow
if (current.condition1) {
    // Process condition1
} else if (current.condition2) {
    // Process condition2
}

 

 

  • Call Sub-Flows from Main Flow:

          

 

 

// Main Flow
if (conditionGroup1) {
    subFlow1.execute();
} else if (conditionGroup2) {
    subFlow2.execute();
}

 

 

 

Explanation

  • Break Down Logic: Use sub-flows to handle specific condition sets.
  • Scripted REST API: Preprocess data and handle conditions before the main flow.

 

Thanks,

Hope this helps.

If my response proves helpful please mark it helpful and accept it as solution to close this thread.