Hi ,
We get different different kinds of response Status and Status codes when we do callouts .
One of the Http Response is
System.HttpResponse[Status=Moved Temporarily, StatusCode=302]
To avoid this we have to follow the code snippet below.
System.HttpResponse[Status=Moved Temporarily, StatusCode=302]
while (res.getStatusCode() == 302) {
req.setEndpoint(res.getHeader('Location'));
res = new Http().send(req);
}
Usually when we get status code as 302 , the server will also provide the new location. We need to extract that from the headers and request it as shown above.
No comments:
Post a Comment