简体   繁体   English

使用 Vimeo API 重命名视频

[英]Rename video with Vimeo API

I'm looking to rename my videos with the Vimeo Api and Google Apps Script.我希望使用 Vimeo Api 和 Google Apps 脚本重命名我的视频。 I succesfully have the API moving videos into folders (using pretty much identical syntax to below) but can't for the life of me get the renaming working.我成功地让 API 将视频移动到文件夹中(使用与下面几乎相同的语法),但我终生无法重命名。 It's extremely frustrating.这非常令人沮丧。

Here is the reference and below is my code - it just returns the video info as if I'm not trying to change anything, even though I'm clearly using a 'PATCH' call, not a 'GET'. 是参考,下面是我的代码-它只是返回视频信息,就好像我没有尝试更改任何内容一样,即使我显然使用的是“PATCH”调用,而不是“GET”。 Where am I meant to put the 'name' parameter??我打算把'name'参数放在哪里?

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

}

When I saw the official document of Edit a video , it seems that name is included in the request body.当我看到Edit a video 的官方文档时,似乎请求正文中包含了name So how about this modification?那么这个改装怎么样呢?

Modified script:修改后的脚本:

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);
}
  • The content type is application/json .内容类型是application/json

Reference:参考:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM