I am trying to use the facebook node business sdk and I am having some issues. I am using an api key from the ad sandbox account.
I am trying to call createAdImage but I get hit with an error that says "The provided image file is invalid". However, it works with the exact same parameters when I just hit the graph API with curl.
Here is my function code
const createAdImage = async (url) => {
console.log("here");
account
.createAdImage([AdImage.Fields.Hash], {
[AdImage.Fields.filename]: url,
})
.then((result) => {
console.log(result);
return result.hash;
})
.catch((error) => {
console.log(error);
});
};
createAdImage("/home/philowe2001/fb-test/AdsSample/philoicon.jpg");
Here is some of the relevant console output
message: 'The provided image file is invalid: The provided image file is invalid. Please check your image path again.',
status: 400,
response: {
error: {
message: 'Invalid parameter',
type: 'OAuthException',
code: 100,
error_subcode: 2490361,
is_transient: false,
error_user_title: 'The provided image file is invalid',
error_user_msg: 'The provided image file is invalid. Please check your image path again.',
fbtrace_id: 'AcOHTk6MviAmBmqB5J242i7'
}
},
Also just in case this is useful, here is my curl code that works
curl \
-F 'filename=@/home/philowe2001/fb-test/AdsSample/philoicon.jpg' \
-F 'access_token=EAAJT1aMW9V0BAGTlre3ZBkkQju5HrQo1zi1CDG9r6sok74PGk7yFynPffGqbGPUZBCNBlYe6EiFNFrc8hoghi4bidCqIVAhx3SNmQEY9JTHc3cb7scgwaok98TXMiJll8o7ZAlWrK1LNBbz0KWpaZByNQmJa2DaAIZAJvXX2Q3aeWo30lbEwdIZCX8KqaEy6EZD' \
https://graph.facebook.com/v15.0/act_1431237097286304/adimages
Thank you.