3

I am new to Firebase. Now I tried to test the notification in postman

enter image description here

but If I test it in the Firebase console, I can able to get the notification.

I used the correct sender ID and API key from the Firebase console.

Please advice me for this issue. I checked some stack, but not solved those answers.

Edit: Payload:

{ "data": {
      "ReferenceKey": "BD",
      "ReferenceValue": "10"
  }, 
  "to" : "fzUHLONY-gY"
}
AL.
  • 36,815
  • 10
  • 142
  • 281
CarinaMj
  • 187
  • 2
  • 14
  • Hi. Can you also include the (raw) sample payload you're sending? – AL. Jan 20 '17 at 09:21
  • { "data": { "ReferenceKey": "BD" , "ReferenceValue": "10" }, "to" : "fzUHLONY-gY" } this is am sending as the payload – CarinaMj Jan 20 '17 at 09:25
  • Is that the exact Registration token? It seems, short. Or did you cut it for security reasons? – AL. Jan 20 '17 at 09:31
  • yeah I have cut that registration token. – CarinaMj Jan 20 '17 at 09:37
  • @CarinaMj Were u able to solve the issue , I am facing bit similar issue.Postman is responding me success but data is not getting stored in firebase – Shifs Mar 29 '19 at 04:33

3 Answers3

3

The 401 Error is most commonly received if you are receiving an Invalid/Wrong Server Key (see my answer here for more details). Simply use the correct Server Key from the Firebase Console.

With regards to your request in Postman, it looks fine. Do note that you don't have to add the Sender ID in the request. See my answer with details on using Postman.

Let me know if you're still encountering any errors.

Graham
  • 7,431
  • 18
  • 59
  • 84
AL.
  • 36,815
  • 10
  • 142
  • 281
  • 1
    I used the server key as Web API Key from the Firebase project settings Which is the correct one ? – CarinaMj Jan 20 '17 at 09:36
  • @CarinaMj You have to use the Server Key, **not** the Web API Key. – AL. Jan 20 '17 at 09:54
  • I already tried that, if i try this then I got the response like this { "multicast_id": 7361428839748873683, "success": 0, "failure": 1, "canonical_ids": 0, "results": [ { "error": "InvalidRegistration" } ] } – CarinaMj Jan 20 '17 at 10:15
1

In the Firebase console, go to Project settings -> Cloud Messaging and try to use the Server Key.

Simon Andersson
  • 751
  • 1
  • 9
  • 29
  • I already tried that, if i try this then I got the response like this { "multicast_id": 7361428839748873683, "success": 0, "failure": 1, "canonical_ids": 0, "results": [ { "error": "InvalidRegistration" } ] } – CarinaMj Jan 20 '17 at 09:30
  • If It's InvalidRegistration then your API is correct but your pushtoken did not update in the server. Log the push token and check with that same as in your saver or not. https://fcm.googleapis.com/fcm/send this is not like sending from the GCM cloud. – AngelJanniee Feb 01 '17 at 03:48
0

Remove sender from header and in body add firebase token id which are valid.Hope it will help you............................................

<code>***Remove sender from header and in body add firebase token id which are valid.Hope it will help you............................................***</code>

Arjun
  • 53
  • 8