varad
varad

Reputation: 8029

Facebook video upload invalid foramat. It should be an image file data

Here I am trying to upload a video to user profile. I have set up javascript sdk and my authentication works well .

I have the following code here..

FB.api(
        `/${user_id}/videos`,
        "POST",
        {
            "file_url": video,
            "description": description,
            "thumb": video_thumbnail,
            "title": title,


        },
        function (response) {
          console.log("fb response")
          console.log(response)
          if (response && !response.error) {
            /* handle the result */
            console.log("video upload response")
            console.log(response)
          }
        });

Here I get the following error ..

code: 100 fbtrace_id: "FD5tVyrH9bS" message: "(#100) Invalid format. It should be an image file data." type: "OAuthException"

I am using file_url and passing url to my video. I guess it should upload the video..

Thank you for the response

Upvotes: 1

Views: 1924

Answers (2)

dalmate
dalmate

Reputation: 481

I confirm that you must post image file data in source field when posting to Facebook. You can test by use Postman. This is example:

var fs = require("fs");
var request = require("request");

var options = { method: 'POST',
  url: 'https://graph.facebook.com/v2.11/2011156779127713/thumbnails',
  headers: 
   { 'Postman-Token': '6c17c103-d8f6-47a5-713b-b3709dde762d',
     'Cache-Control': 'no-cache',
     'content-type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' },
  formData: 
   { access_token: 'test',
     is_preferred: 'true',
     source: 
      { value: 'fs.createReadStream("./Downloads/923249_818835191462845_1528674847924045075_n.jpg")',
        options: 
         { filename: './Downloads/923249_818835191462845_1528674847924045075_n.jpg',
           contentType: null } } } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Upvotes: 1

Taran
Taran

Reputation: 14176

The problem isn't the video or the URL, it's the thumb parameter.

The thumb parameter needs to be 'file data', not the URL.

As to what format the image needs to be in..please let me know if you find out! I'm asking the same here.

The facebook API is terrible...

Upvotes: 0

Related Questions