Recommended solutions based on your search
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.
401 means "Unauthorized", so there must be something with your credentials. You need to pass the authentication to let the server know its a valid user. Check whether the authentication details are provided.
Solutions on the web
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).