2

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

enter image description here

I am not sure what I am missing & last I am using correct server api key.

Please assist & thanks in advance.

N Sharma
  • 33,489
  • 95
  • 256
  • 444

3 Answers3

0

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.

Fahad Ishaque
  • 1,916
  • 1
  • 17
  • 21
0

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

N Sharma
  • 33,489
  • 95
  • 256
  • 444
0
  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

Sairam
  • 169
  • 12