Я получаю сообщение об ошибке 401 при попытке нажать на URL-адрес. Я использую аутентификацию HTTP BASIC, используя «Ключ приложения» в качестве имени пользователя и «Главный секрет приложения» в качестве пароля. Я использую JAVA HttpsUrlConnection класс. Я не знаю, что не так с моим кодом.
` URL url = new URL("https://go.urbanairship.com/api/push");
HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setUseCaches(false);
connection.setRequestProperty("Content-Type","application/json");
connection.setRequestProperty("Content-Length", Integer.toString(data.length()));
String authString = "xxxxxxxxxxxxxxxxxx:yyyyyyyyyyyyyyyyy";
authString = Base64Coder.encodeString(authString);
connection.setRequestProperty("Authorization","Basic "+ authString);
OutputStreamWriter wr = new OutputStreamWriter(connection.getOutputStream());
wr.write(data);
wr.flush();
int responseCode = connection.getResponseCode();
//Get the response
String responseLine = new BufferedReader(new InputStreamReader(connection.getInputStream())).readLine();`