I would like to send a HTTPS Get Request to the google shopping api however nothing is quite working for me, for example here is what I\'m trying at the moment:
You can try it this way maybe using URLConnection class
String error = ""; // string field
private String getDataFromUrl(String demoIdUrl) {
String result = null;
int resCode;
InputStream in;
try {
URL url = new URL(demoIdUrl);
URLConnection urlConn = url.openConnection();
HttpsURLConnection httpsConn = (HttpsURLConnection) urlConn;
httpsConn.setAllowUserInteraction(false);
httpsConn.setInstanceFollowRedirects(true);
httpsConn.setRequestMethod("GET");
httpsConn.connect();
resCode = httpsConn.getResponseCode();
if (resCode == HttpURLConnection.HTTP_OK) {
in = httpsConn.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(
in, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
sb.append(line).append("\n");
}
in.close();
result = sb.toString();
} else {
error += resCode;
}
} catch (IOException e) {
e.printStackTrace();
}
return result;
}