Почтовый запрос HTTP: ошибка 400, обмен сообщениями в темах Firebase

Я пытаюсь реализовать Firebase Topic Messaging в приложении для Android, и я пытаюсь создать HTTP-пост-запрос, и я получаю код ответа 400. Я посмотрел на различные решения, но ни одно из них, похоже, не Помогите.

Вот где я называю подкласс AsyncTask:

try{new FirebaseSendMessage().execute("Hello world");}
                catch (Exception e) {
                    Log.d("Exception", e.toString());
                }

Вот мой подкласс класса Async Task.

class FirebaseSendMessage  extends AsyncTask<String, Integer, Double> {
private final static String USER_AGENT = "Mozilla/5.0";
private final static String AUTH_KEY = "<My firebase authorization key obtained from firebase>";

private Exception exception;

protected Double doInBackground(String... params) {
    try {
        sendRequest(params);
    } catch (Exception e) {
        this.exception = e;
    }
    return null;
}

protected void onPostExecute(Long l) {
    // TODO: check this.exception
    // TODO: do something with the feed
}


public void sendRequest(String... params) {
    try {
        String urlString = "https://fcm.googleapis.com/fcm/send";
        URL ur,l = new URL(urlString);
        HttpURLConnection con = (HttpURLConnection) url.openConnection();
        con.setDoOutput(true);
        con.setRequestMethod("POST");
        con.setRequestProperty("Content-Type", "application/json");
        con.setRequestProperty("Authorization", "key=" + AUTH_KEY);
        String postJsonData = "{\"to\": \"/topics/news\"\"data\": {\"message\": \"This is a Firebase Cloud Messaging Topic Message!\"}";
        con.setDoOutput(true);

        DataOutputStream wr = new DataOutputStream(con.getOutputStream());
        wr.writeBytes(postJsonData);
        wr.flush();
        wr.close();

        int responseCode = con.getResponseCode();
        System.out.println("POST Response Code :: " + responseCode);

        if (responseCode == HttpURLConnection.HTTP_OK){
            System.out.println("succeeded");
        }
        /*InputStream is = con.getInputStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String line = null;
        while ((line = br.readLine()) != null) {
            System.out.println(line);
        }
        //con.disconnect();*/
    }
    catch(IOException e){
        Log.d("exception thrown: ", e.toString());
    }
}

}

Ошибка:I/System.out: POST Response Code :: 400

Пожалуйста, дайте мне знать, если для отладки требуются дополнительные фрагменты кода. Заранее спасибо!

Ответы на вопрос(2)

Ваш ответ на вопрос