Problem with Attachment API In Pega
We have a Pega-hosted REST service API that accepts requests containing document data as an attachment stream. We have an validation in api request to reject the request if document is size is more than 25MB however when the client sends a request with a document size is 20 MB, we encounter the following error:
"The request could not be understood by the server due to malformed syntax."
From our investigation, it appears that if the streamed content length exceeds 20,000,000 bytes, the JSON mapping utility (JSONMappingUtils
) fails to process the request.
Questions:
-
Is it straightforward to increase this 20 MB limit in Pega or the underlying JSON parser configuration?
-
What are the recommended best practices or alternatives for handling large document uploads via a REST API in Pega?
We are looking for guidance on how to manage large files efficiently without hitting these parsing or memory limits.
Log file:-
We have a Pega-hosted REST service API that accepts requests containing document data as an attachment stream. We have an validation in api request to reject the request if document is size is more than 25MB however when the client sends a request with a document size is 20 MB, we encounter the following error:
"The request could not be understood by the server due to malformed syntax."
From our investigation, it appears that if the streamed content length exceeds 20,000,000 bytes, the JSON mapping utility (JSONMappingUtils
) fails to process the request.
Questions:
-
Is it straightforward to increase this 20 MB limit in Pega or the underlying JSON parser configuration?
-
What are the recommended best practices or alternatives for handling large document uploads via a REST API in Pega?
We are looking for guidance on how to manage large files efficiently without hitting these parsing or memory limits.
Log file:-
Caused by: com.fasterxml.jackson.core.exc.StreamConstraintsException: String value length (20015482) exceeds the maximum allowed (20000000, from `StreamReadConstraints.getMaxStringLength()`) at com.fasterxml.jackson.core.StreamReadConstraints._constructException(StreamReadConstraints.java:549) ~[jackson-core-2.17.2.jar:?] at com.fasterxml.jackson.core.StreamReadConstraints.validateStringLength(StreamReadConstraints.java:484) ~[jackson-core-2.17.2.jar:?] at com.fasterxml.jackson.core.util.ReadConstrainedTextBuffer.validateStringLength(ReadConstrainedTextBuffer.java:27) ~[jackson-core-2.17.2.jar:?] at com.fasterxml.jackson.core.util.TextBuffer.finishCurrentSegment(TextBuffe
endpoint route :-/prweb/api/MyAPPServices/v2/Applications/W-1001/Document
Sample JSON :-
{
"Name": "certOfEmpl.txt", "Content": "20MB encoded stream content", "Type": "EmployeeCeritifcate", "ExternalId": "ABCD", "CustomerID": "6385594031"
}