java.io.IOException

Server returned HTTP response code: 401 for URL: https://android.googleapis.com/gcm/sendPlease ensure that API_KEY has been replaced by the server API key, and that the device's registration token is correct (if specified).

Samebug tips1

Check if you didn't set RequestProperty Content-Type to the wrong type or if you're trying to send the wrong file to the server.

Don't give up yet. Our experts can help. Paste your full stack trace to get a solution.

Solutions on the web22177

  • Server returned HTTP response code: 401 for URL: https://android.googleapis.com/gcm/sendPlease ensure that API_KEY has been replaced by the server API key, and that the device's registration token is correct (if specified).
  • Server returned HTTP response code: 401 for URL: https://android.googleapis.com/gcm/send
  • via Stack Overflow by chako
    , 1 year ago
    Server returned HTTP response code: 401 for URL: https://android.googleapis.com/gcm/send
  • Stack trace

    • java.io.IOException: Server returned HTTP response code: 401 for URL: https://android.googleapis.com/gcm/sendPlease ensure that API_KEY has been replaced by the server API key, and that the device's registration token is correct (if specified). at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1840) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254) at gcm.play.android.samples.com.gcmsender.GcmSender.main(GcmSender.java:82)

    Write tip

    You have a different solution? A short tip here would help you and many other users who saw this issue last week.

    Users with the same issue

    Unknown user
    Once, 10 months ago
    35 times, 11 months ago
    Once, 11 months ago
    3 times, 1 year ago
    Unknown user
    Once, 1 year ago
    92 more bugmates