JackNapier
JackNapier

Reputation: 448

Set vimeo thumbnail from video with Apps Script - it keeps returning the stripes image

Unlike most queries here I'm trying to set the thumbnail of a video using the API.
For this I'm not uploading an image, I'm trying to get an image 15 seconds into the video and setting it active as the thumbnail.

When I do this via the API documentation test section it works perfectly fine, but the below code only generates the error stripes image and wont set it to active.
Any thoughts?

Here is what the documentation suggests, and note that I have the 'upload' privileges for my app.

I believe it has something to do with the 'payload' line, and the "{15}".

vimeotoken = "###############....etc";

function setthumbnail(){

      var url = 'https://api.vimeo.com/videos/' + '##########' + '/pictures';

      var options = { 
        'method': 'POST',
        'muteHttpExceptions': true,
        'contentType': 'application/json',
        'headers': {
          'Accept':'application/vnd.vimeo.*+json;version=3.4',
          'Authorization': "Bearer " + vimeotoken,
        },
        'payload': JSON.stringify([{ "time": "{15}", "active": true }]),
      };
      var response = UrlFetchApp.fetch(url, options);  
      Logger.log(response);
      
}

Upvotes: 1

Views: 317

Answers (1)

JackNapier
JackNapier

Reputation: 448

Turns out all I needed was to remove the array for the payload line.
From:

'payload': JSON.stringify([{ "time": "{15}", "active": true }]),

To:

'payload': JSON.stringify({ "time": "{15}", "active": true }),

Upvotes: 1

Related Questions