Kapuchon
Kapuchon

Reputation: 134

Sending a notification through Firebase's FCM API Test

I'm currently trying to send a notification using the " Try this API " interface of Firebase. I filled my Request Body with this :

{
  "validateOnly": false,
  "message": {
    "notification": {
      "body": "Body",
      "title": "Title"
    }
  }
}

and the RequestParameters with

projects/myprojectid

I didn't check the Google API Key since my project doesn't have one, but I checked the Google OAuth 2.0.

After executing, I get this error :

{
  "error": {
    "code": 400,
    "message": "Recipient of the message is not set.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "field": "message",
            "description": "Recipient of the message is not set."
          }
        ]
      },
      {
        "@type": "type.googleapis.com/google.firebase.fcm.v1.FcmError",
        "errorCode": "INVALID_ARGUMENT"
      }
    ]
  }
}

After some research, I don't understand what is missing in the request. Are all the parameters mandatory for the request ?

Upvotes: 2

Views: 3227

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598603

You're not specifying who the message is for, which is what the error message is trying to tell you. You can do by either including a token key with one of more device tokens, or a topic or condition key in the JSON.

Also see the Firebase documentation on building requests to send a message for more information and examples of each of these.

Upvotes: 3

Related Questions