Exceeding Max REST POST Request Limit Issue

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2018 01:18 PM
I'm performing a POST via REST in ServiceNow due to data size limits, which as I understand it, I should be able to increase. I've already doubled the default values for the two System Properties as specified in ControllingMaxRequestSize but continue to receive errors such as
{"error":{"message":"Exception while reading request","detail":"Rejected large REST payload with content-length = 12126813 bytes. Max allowed: 10485760 bytes."},"status":"failure"}
The "Max allowed" value does not look to have increased based on those System Properties. So if that's not the solution, how can I POST a large payload to ServiceNow?
--------
FWIW this is my REST code:
var target_table = <target_table_name>;
var requestBody = <huge_json_string>;
var request = new sn_ws.RESTMessageV2();
request.setEndpoint(gs.getProperty('glide.servlet.uri') + 'api/now/table/' + target_table);
request.setHttpMethod('POST');
request.setAuthenticationProfile('basic', <sys_id>);
request.setRequestHeader("Accept","application/json");
request.setRequestHeader('Content-Type','application/json');
request.setRequestBody(requestBody);
var response = request.execute();
gs.log(response.getBody());
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2018 03:38 PM
try to split your JSON string into smaller chunks.
Have you tried both of the following?
Option 1 (uses JavaScript):
var json = new JSON();
var jsObj = json.decode(stringValue);
Option 2 (uses Java):
var json = new JSONParser();
var jsObj = json.parse(stringValue);
Regards,
Sachin