Generate push notification through Firebase
<p>I'm trying to generate a notification from my REST service. The drawback is that not send, although fcm.googleapis.com/fcm/send responds that was successful.
This I do in two ways, first by the module http:</p>

<pre><code>var http = require('http');
    var options = {
        'hostname': 'fcm.googleapis.com',
        'path': '/fcm/send',
        'method': 'POST',
        'headers': {
            'Authorization': 'key=&lt;Key Server&gt;',
            'Content-Type': "application/json"
        }
    };
    var data = {
        'to':tokenPush,
        'notification':notification
    };   
    var requestHttp = http.request(options, function(res){
        res.setEncoding('utf8');
        res.on('data', function (chunk) {
            console.log(chunk);
        });
    });
    requestHttp.on('error', function(e) {
        console.log('problem with request: ' + e.message);
    });
    requestHttp.end(JSON.stringify(data));
</code></pre>

<p>The other way is through a command from the shell:</p>

<pre><code>var exec = require('child_process').exec;
    var     cmd = 'curl -X POST --header "Authorization: key=&lt;Key Server&gt;" ';
    cmd +=  '--Header "Content-Type: application/json" https://fcm.googleapis.com/fcm/send ';
    cmd +='-d \'{"to":"&lt;Token Client&gt;","notification":{"title":"Validación","body":"'+(new Date()).getTime()+'","sound":"default"}}\'';
    console.log("=====================================");
    console.log(cmd);
    console.log("=====================================");
    exec(cmd, function(error, stdout, stderr) {
      if (error) {
          console.log("=====================================");
          console.error('exec error:'+error);

      }
        console.log("=====================================");
        console.log('stdout: '+stdout);
        console.log('stderr: '+stderr);
    });
</code></pre>

<p>In both cases the answer is:</p>

<p>{ "Multicast_id":  "success": 1, "failure": 0, "canonical_ids": 0, "results": [{ "message_ID": ""}]}.</p>

<p>The code for the shell works correctly when I run it from a separate file with the "node" command.</p>

<p>What I can be wrong?</p>