Youtube API v3 video.update响应400 - invalidRequest

时间:2014-01-26 19:01:55

标签: youtube-api http-status-code-400

问题相当简单,我无法向youtube api video.update提出一个非常简单的请求而没有得到400响应,原因是'invalidRequest'。我正在使用Youtube API Explorer(https://developers.google.com/youtube/v3/docs/videos/update)。该帐户已获得授权。其他API方法,如playlists.update和videos.list工作得很好。请帮助解决此video.update请求。

发送测试请求:

PUT https://www.googleapis.com/youtube/v3/videos?part=snippet&key={YOUR_API_KEY}

Content-Type:  application/json
Authorization:  Bearer {AUTH_KEY}
X-JavaScript-User-Agent:  Google APIs Explorer

{
 "id": "{VIDEO_ID}",
 "snippet": {
  "title": "title change to test1",
  "description": "description change to test"
 }
}

收到回复:

    400 Bad Request

- Hide headers -

cache-control:  private, max-age=0
content-encoding:  gzip
content-length:  134
content-type:  application/json; charset=UTF-8
date:  Sun, 26 Jan 2014 18:48:13 GMT
expires:  Sun, 26 Jan 2014 18:48:13 GMT
server:  GSE

{
 "error": {
  "errors": [
   {
    "domain": "youtube.video",
    "reason": "invalidRequest",
    "message": "Bad Request"
   }
  ],
  "code": 400,
  "message": "Bad Request"
 }
}

1 个答案:

答案 0 :(得分:4)

似乎 snippet.categoryId 属性是必需的,并且没有记录您必须指定它。将此属性添加到请求主体可以解决问题。