I am accessing an API, but when i debug the response it shows this message [Status=Moved Temporarily, StatusCode=302]. what should i do to access my required response.. my code is given below
public class WebServiceCall{
public String getResult{get;set;}
public PageReference submit() {
getResult=getData();
return null;
}
public String getData()
{
HttpRequest req= new HttpRequest();
Http http = new Http();
req.setMethod('GET');
String url = 'http://www.geocko.com/api/orders/?app_id=xxxxxxxxxxxxx';
req.setEndpoint(url);
HttpResponse res = http.send(req);
String json = res.getBody();
System.debug(res.getBody());
try {
JSONObject j = new JSONObject( json );
return parseJson(j);
} catch (JSONObject.JSONException e) {
return 'Error parsing JSON response from Web: '+e;
}
}
public String parseJson(JSONObject resp){
return resp.getString('type');
}
}