This is because you are using legacy HTTP API which doesn't support image payload. Try migrating to HTTP v1 API and you'll be able to send image payload. Follow these links.
Migration guide.
Send image in notification payload
When migrating to HTTP v1, you'll need oAuth token and in case you don't know how to generate it, I'll provide step by step guide here.
To create oAuth token, follow these steps.
Step 1. Get serviceaccount json file from firebase console.
Go to firebase console -> project setting -> service account tab and click generate new private key to download json file. The json file contains some credential information.
Step 2. Generate token
Generating token will require running some program code using node,python or java and here I'll be using node.
Create generatekey.js file with below code, and change path of json file inside code.
var {google} = require("googleapis");
// Load the service account key JSON file.
var serviceAccount =
require("path/to/downloaded.json"); //change path to your downloaded json file
// Define the required scopes.
var scopes = [
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/firebase.messaging"
];
// Authenticate a JWT client with the service account.
var jwtClient = new google.auth.JWT(serviceAccount.client_email,
null,serviceAccount.private_key,scopes);
// Use the JWT client to generate an access token.
jwtClient.authorize(function(error, tokens) {
if (error) {
console.log("Error making request to generate access token:",
error);
} else if (tokens.access_token === null) {
console.log("Provided service account does not have permission to generate access tokens");
} else {
var accessToken = tokens.access_token;
console.log(accessToken);
// See the "Using the access token" section below for information
// on how to use the access token to send authenticated requests to
// the Realtime Database REST API.
}
});
Run generatekey.js file from terminal with command
node genereatekey.js and it will print OAuth2 token.