问题
Hi I am trying to push the notification from rest client to android app. I am doing like below -
URL - https://android.googleapis.com/gcm/send
Method - POST
Headers - Authorization: my_server_key
I always get this message
Status Code: 401 Unauthorized Alternate-Protocol: 443:quic,p=0.002 Cache-Control: private, max-age=0

I am not sure what I am missing & last I am using correct server api key.
Please assist & thanks in advance.
回答1:
Push notification uses Web Socket
. You cannot do this using HTTP protocol
unless you have a server side implementation set up to respond to your request through Web Socket.
回答2:
I set this values in the header then it is working fine for me.
Below is the header key & value.
A) Authorization: & it value likes key=API_KEY
B) Content-Type: application/json
回答3:
I hope you are done with your request but it will help to others
You have to send like this
In head
-------
Headder Value
Authorization key=your value
Content-Type application/json
In Body
-------
Something like this
{
"registration_ids" : ["Your id"],
"data" : {
"message":"Your message"
}
}
Hope it will help
来源:https://stackoverflow.com/questions/26008860/how-to-push-notification-from-rest-client-for-testing-purpose