I'm trying to make a GMAIL API call to the history endpoint using a historyId. This call works on Postman and I receive a json response as I should. But when I'm trying to implement the same in Android Studio, it returns a 404 Not Found Error. Can anyone help me with this?
URL urlHist = new URL("https://www.googleapis.com/gmail/v1/users/me/history?startHistoryId="+historyId);
HttpURLConnection connHist = (HttpURLConnection) urlHist.openConnection();
connHist.setRequestProperty("Authorization",token);
connHist.setRequestMethod("GET");
connHist.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
connHist.setRequestProperty("Accept","application/json");
connHist.setDoOutput(true);
connHist.setDoInput(true);
DataOutputStream os = new DataOutputStream(connHist.getOutputStream());
os.flush();
os.close();