使用Vimeo API重命名视频

问题描述 投票:0回答:1

我正在使用Vimeo Api和Google Apps脚本重命名我的视频。我成功地将API的视频移动到了文件夹中(使用与下面几乎相同的语法),但是我一生都无法正常工作。非常令人沮丧。

Here是参考,下面是我的代码-即使我显然使用的是'PATCH'调用,而不是'GET',它只是返回视频信息,好像我没有尝试更改任何内容。我要在哪里放置“名称”参数?

function renameVideo(){

  var newName = 'thisismynewname';
  var url = 'https://api.vimeo.com/videos/_________?name=' + newName;

  var options = { 
    'method': 'PATCH',
    'muteHttpExceptions': true,
    'contentType': 'application/json',
    'headers': {
      'Accept':'application/vnd.vimeo.*+json;version=3.4',
      'Authorization': "Bearer " + token,
    },
    //Note that I've also tried 'name' : 'thisismynewname' here too
  };

  var response = UrlFetchApp.fetch(url, options);  
  Logger.log(JSON.parse(response).name); //it just returns the *current* name not the new one, and doesn't change it

}
javascript api google-apps-script vimeo vimeo-api
1个回答
0
投票

[当我看到the official document of Edit a video时,似乎name已包含在请求正文中。那么如何修改呢?

修改的脚本:

function renameVideo(){
  var newName = 'thisismynewname';
  var url = 'https://api.vimeo.com/videos/_________';  // Modified

  var options = { 
    'method': 'PATCH',
    'muteHttpExceptions': true,
    'contentType': 'application/json',
    'headers': {
      'Accept':'application/vnd.vimeo.*+json;version=3.4',
      'Authorization': "Bearer " + token,
    },
    'payload': JSON.stringify({name: newName})  // Added
  };

  var response = UrlFetchApp.fetch(url, options);  
  Logger.log(JSON.parse(response).name);
}
  • 内容类型为application/json

参考:

© www.soinside.com 2019 - 2024. All rights reserved.