首页 > 解决方案 > 使用 YouTube Data API v3 更新视频标题会给出“消息”:“解析错误”

问题描述

我正在尝试使用带有 python 的 YouTube API V3 更改视频标题。我正在使用requests模块发送一个 put 请求。这是我的代码:

import requests

url = "https://www.googleapis.com/youtube/v3/videos?part=snippet&key=[KEY] HTTP/1.1"

headers= {
     'Authorization': 'Bearer [ACCESS_KEY]',
     'Accept': 'application/json',
     'Content-Type': 'application/json',
}

data = {
          'id': 'azTrAGHcPX4',
          'snippet': {
            'title': 'This video has views',
            'categoryId': '22',
          }
        }


json = requests.put(url,headers=headers,data=data)

print(json),我收到以下错误:

{'error': {'errors': [{'domain': 'global', 'reason': 'parseError', 'message': 'Parse Error'}], 'code': 400, 'message': 'Parse Error'}}

关于这个错误的任何线索?

标签: pythonyoutube-data-apigoogle-apis-exploreryoutube-api

解决方案


推荐阅读