Loading

Script-thrown exception" error on HTTP callouts to AWS as of Spring ’22

Data pubblicazione: Jul 14, 2023
Descrizione
In Spring ’22, we switched the internal HTTP client implementation for AWS callouts using Named Credentials for a mixture of security and performance reasons. As a result, customers may need to handle certain HTTP headers differently.
In Winter ’22 and earlier, the the Content-Length header was silently ignored even when specified explicitly in customers' Apex code. In Spring ’22, the header is not ignored, and causes issues regardless of whether or not the value matches the actual length of the content. Hence, callouts to AWS may fail with a "System.CalloutException: Script-thrown exception" when the Content-Length header is specified in the code.

Affected Code:
--
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:aws');
req.setMethod('POST');
req.setBody('dummy');
req.setHeader('Content-Length','5');
HTTPResponse res = new Http().send(req);
--
Risoluzione
Remove or comment out the statement to set the Content-Length header.
--
// req.setHeader('Content-Length','5');
--
Numero articolo Knowledge

000393013

 
Caricamento
Salesforce Help | Article