Facebook Marketing API HTTP POST error - The provided image file is invalid. Please check your image path again

50 Views Asked by At

I am trying to upload an image to Facebook but am getting the error "The provided image file is invalid. Please check your image path again."


As a noob, I was able to create the campaigns and the ad sets (which was a huge challenge - but I am happy I did it). Unfortunately, I am stuck in the ads (ad creative).

I read many questions here and on the internet but still can't understand how to do it.

Questions 1, 2, 3, and more...


According to the documentation, I first need to create an AdImage object from an image file. (link here)

  -F 'filename=@<IMAGE_PATH>' \
  -F 'access_token=<ACCESS_TOKEN>' \
  https://graph.facebook.com/v<API_VERSION>/act_<AD_ACCOUNT_ID>/adimages


I tried to do it with the Graph Explorer using an image file that is on my desktop, but it did not work:

POST to https://graph.facebook.com/v<API_VERSION>/act_<AD_ACCOUNT_ID>/adimages
{
         "filename": "@/Users/myname/Desktop/test_1.png"
}


I do not understand how I can upload an image file using HTTP and I have two questions:

1. What am I doing wrong in the Graph Explorer? What should I change to work?

2. How can I download/upload an image using an HTTP POST request?


My final goal is to have a Make scenario that will read the images from a Google Drive folder, upload them to the Facebook Media Library, and then I will create a campaign.

Make returns a lot of data from Google Drive files, such as URL, sharable link, image format, mime and many more. But I don't know how to upload it based on a URL, for example.

So, what I need is a POST request that will get the image data and upload to Facebook Media Library.


To illustrate, let's say I would have something like this - how can I make the POST request work and read/upload the image?

POST to https://graph.facebook.com/v<API_VERSION>/act_<AD_ACCOUNT_ID>/adimages
{
         "access_token": "<ACCESS_TOKEN>,
         "filename": "https://drive.google.com/uc?export=download&id=1uQQqMhzakhKoBGcHeI6zCP_Nu"
}

I think that if I am able to download it from Google Drive and upload it to the Media Library to have the image hash, I will get to where I need to.

0

There are 0 best solutions below