check no response f...
 
Notifications
Clear all

[Solved] check no response from remote server rest api

2 Posts
1 Users
0 Likes
775 Views
Posts: 205
 CWL
Admin
Issue starter
(@cwl)
Member
Joined: 11 years ago

How to take some action if there in no response, server timed out in a rest api call?

Issue Tags
1 Reply
Posts: 205
 CWL
Admin
Issue starter
(@cwl)
Member
Joined: 11 years ago

Figured it out. Use the following code:

        req.setHeader('Content-Type', 'application/json');
        Http http = new Http();
        HTTPResponse res;
        try {
            res = http.send(req); 
        } catch (System.CalloutException e) {
            // add required action here, like calling the rest api again if need.
        }

Just put it in a try catch block and use the System.CalloutException

Reply
Share: