Trying to send data using google's FCM with TTL

So this is the answer I received from Google's Firebase Support, they found out what I did wrong here:

Looking at your code, it seems that you have some irregularities with your request format. The headers are for the Legacy FCM API while the format of the payload is for the HTTP v1 FCM API.

If you want to use the Legacy API, you'll have to omit the Android specific payload and use time_to_live instead of ttl. But if you prefer using the HTTP v1 API, you'll have to build the request as mentioned here and use the token parameter instead of to.

The problem is that I combined two methods of requests. The headers of the requested match the Legacy API's format, while the request itself was in HTTP v1 FCM API format.

This part of the request belongs to the HTTP v1 API fomat:

"android": {
  "ttl": "10s" 
}

While the correct way to do it is without the "android" tag and using just a time_to_live tag:

"time_to_live": 10 //The time in seconds

This is how my full request looks like now:

var http = new XMLHttpRequest();
http.open("POST", "https://fcm.googleapis.com/fcm/send", true);
http.onreadystatechange = function() {};
http.setRequestHeader("Content-type", "application/json");
http.setRequestHeader("Authorization", "key=*****");
http.send(JSON.stringify({
    "to": "/topics/all",
    "data": {
        "Title": "Test",
        "areas": "Dan, Ayalon",
    },
    "time_to_live": 10
}));       

If you have any questions please comment