第一个错误:读取到第三方答复后超时

时间:2019-10-25 08:32:34

标签: rest api salesforce apex

当我点击第三方端点以获取响应时,它在我的批处理类中给出了异常

 HTTP h = new HTTP();
    HTTPRequest req = new HTTPRequest();
    req.setEndPoint('MyEndpoint');
    req.setMethod('GET');
    req.setHeader('Authorization', 'Bearer '+accTokenWrpObj.access_token);
    req.setHeader('Content-Type', 'application/json');
    req.setTimeout(120000);
    HTTPResponse res = h.send(req);
    if(res.getStatusCode() == 200){
        CustomerWrapper customerWrapObj = (CustomerWrapper)JSON.deserialize(res.getBody(), CustomerWrapper.CLASS);
        return customerWrapObj.value;
    }
    else if(res.getStatusCode() == 401){
        getAccessToken();
        req.setHeader('Authorization', 'Bearer '+accTokenWrpObj.access_token);
        res = h.send(req);
        CustomerWrapper customerWrapObj = (CustomerWrapper)JSON.deserialize(res.getBody(), CustomerWrapper.CLASS);
        return customerWrapObj.value;
    }
    return null; 

我甚至已经使用了最大标注时间120000毫秒)。有什么办法可以解决这个问题?

谢谢

0 个答案:

没有答案