I am calling REST API method to update some data to another system from apex but getting "common.apex.runtime.impl.ExecutionException: Read timed out" exception.

Here is my request code

HttpRequest httpReq2 = new HttpRequest();
httpReq2.setEndpoint(endPoint + '/BoothSales/Customers?Id=' + '12345' + '&companyName=' + 'TestCompany'+ '&phone='+ '65465464');           
httpReq2.setHeader('Content-Length', '1024');
httpReq2.setHeader('Authorization', 'Bearer ' + token);
httpReq.setHeader('Content-Type', 'x-urlformencoded;application/json;charset=UTF-8');

Http http = new Http();      
HttpResponse httpRes2 = http.send(httpReq2);
System.debug('#####httpRes2: ' + httpRes2);

I tried the same request using Postman and it takes about 400ms and got a successful response. Please help me to find the problem in the above code.


1 Answer 1


If the body is not present we can specify the length as 0.

httpReq2.setHeader('Content-Length', '0');

Now, I got a successful response.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .