Использую такой код, но в ответ получаю:
{"code":201, "error":"missing user password}
В чем причина?
public static String httpGet(String url) {
HttpsURLConnection connection = null;
InputStream inputStream = null;
try {
connection = (HttpsURLConnection) new URL(url).openConnection();
connection.setRequestMethod("GET");
connection.setDoInput(true);
connection.setRequestProperty("X-Parse-Application-Id", PARSE_APP_ID);
connection.setRequestProperty("X-Parse-REST-API-Key", PARSE_REST_API);
connection.setRequestProperty("X-Parse-Revocable-Session", "1");
connection.setRequestProperty("username", USERNAME);
connection.setRequestProperty("password", PASSWORD);
connection.connect();
boolean isError = connection.getResponseCode() >= 400;
inputStream = isError ? connection.getErrorStream() : connection.getInputStream();
String contentEncoding = connection.getContentEncoding() != null ? connection.getContentEncoding() : "UTF-8";
return IOUtils.toString(inputStream, contentEncoding); //Apache Commons Lang
} catch (Exception e) {
throw new IllegalStateException(e);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
if (connection != null) {
connection.disconnect();
}
}
}