1

Post Request:

URL:

https://fcm.googleapis.com/fcm/send

enter image description here

Headers:

Content-Type: application/json
Authorization: key=AAAAAsmF578:APA91b...90f

enter image description here

Body:

{
    "to": "fCF...ZFK", 
    "notification": {
        "title": "Foo",
        "body": "Bar"
    }
}

enter image description here


Response:

enter image description here

However, if I use Firebase Notification composer to send a notification on my Android device using the same FCM token fCF...ZFK I do receive a notification. What am I doing wrong here in the Postman? I've already tried several answers related to this on SO but didn't quite get any useful answer.

iDecode
  • 22,623
  • 19
  • 99
  • 186
  • I doubt if it's the `%0A` (LF) character and it's visible in postman too... Can you manually retype the URL instead of copying from docs and try? `/fcm/send` and not `/fcm/send%0A` – Dharmaraj Aug 15 '21 at 07:14
  • @Dharmaraj You're genius! It worked, no errors now. However, I still didn't see any notification. – iDecode Aug 15 '21 at 07:17
  • Did you get a successful response from the API? I'm not sure if that could be some delay in FCM then. – Dharmaraj Aug 15 '21 at 07:18
  • @Dharmaraj Yes, I do. Here's the response `"success": 1, "failure": 0, "results": ...` but no notifications yet. I'll wait for a couple of more mins. – iDecode Aug 15 '21 at 07:19
  • Yes then it maybe the delay but atleast the API URL is fixed now ;) – Dharmaraj Aug 15 '21 at 07:20

1 Answers1

0

There's a Line Feed (LF) character in your URL (%0A after URL encoding) which is not valid API URL. That may have been added while copying from the documentation or other source.

The URL should be /fcm/send instead of /fcm/send%0A.

Dharmaraj
  • 47,845
  • 8
  • 52
  • 84
  • Do I need to ask a separate question for not being able to see a notification using this same request? – iDecode Aug 15 '21 at 07:24
  • @iDecode I'd recommend so as that might be a totally new issue which hasn't been discovered yet or perhaps an issue on client device? [Firebase Cloud Messaging notification not received by device](https://stackoverflow.com/questions/37351354/firebase-cloud-messaging-notification-not-received-by-device) could be useful. – Dharmaraj Aug 15 '21 at 07:27