Script thrown exception in Apex callouts
Last updated 9 days ago ·Reference W-8243224 ·Reported By 42 users
When a server responds to an apex callout with empty response body along with Content-Encoding header set to gzip, apex throws System.CalloutException: Script-thrown exception
1) Create an endpoint which returns an empty response body (http status code can be 204 or 200 ) and a response header "Content-Encoding":"gzip"
2) Make a rest callout to the above endpoint from apex.
Sample code snippet -
Http http = new Http();
HttpRequest request = new HttpRequest();
HttpResponse response = http.send(request);
Execute the snippet and you will see the below Error.
Line: 6, Column: 1
System.CalloutException: Script-thrown exception
When the response body is empty remove Content Encoding header from response headers
Reported By (42)
Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.