Firebase Push Notification via HTTP Node

How to use this Below cURL Format in HTTP Request Node

curl -X POST -H "Authorization: key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -H "Content-Type: application/json" -d '{
  "notification": {
    "title": "Hello World",
    "body": "Test Push",
    "icon": "https://example.com/assets/icons/Icon-48.png",
    "click_action": "https://example.com"
  }
  "registration_ids": ["eUhmaO_NNL88ZoMSfE3eE8:APA91bFfIolITf2y4dn5o-6m-TregQFhVSy1iNn6RnXX3c2Y6yMPi_fkVzEcavzZ4oV9jAT2cGdItZ-D8N-fR4kXX_CXOInT5ZtcSb_rqWy8kWgb42fgJETlgL-xwHmTissNzUgG-gqc", "eDFeL9gn8rLQVG8W-O09CN:APA91bGCssz7IMdaexXRCx-SFTRDO3X0LEiYWrzVbAydIHln3456Z3ENLAERFzV-lnrhLhjTQGzP_uFDUW406dGJjMOtp_j5rRxhrlQgchyX3mZV4MEIfRhohjxboTBpiXC54zXeCDqG"]
}' "https://fcm.googleapis.com/fcm/send"
1 Like

Hey @mskian!

I am sharing an example that might help you.

{
  "nodes": [
    {
      "parameters": {
        "authentication": "headerAuth",
        "requestMethod": "POST",
        "url": "https://fcm.googleapis.com/fcm/send",
        "jsonParameters": true,
        "options": {
          "bodyContentType": "json"
        },
        "bodyParametersJson": "{\n    \"notification\": {\n        \"title\": \"n8n\",\n        \"body\": \"Sending from n8n!\",\n        \"click_action\": \"http://localhost:3000/\"\n    },\n    \"to\": \"TOKEN\"\n}"
      },
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        450,
        450
      ],
      "credentials": {
        "httpHeaderAuth": "fcm"
      }
    }
  ],
  "connections": {}
}

I have set the Authentication method to Header Auth and I am configuring my Server Key. The below image should help you better understand how I have set my credentials.

The JSON in the body might be different for you, depending on the content.

I hope this helps! :slightly_smiling_face:

3 Likes

@harshil1712 Thanks a Lot Perfect :100:

2 Likes