【问题标题】:YouTube V3 API Playlistitems resourceIdRequiredYouTube V3 API 播放列表项 resourceIdRequired
【发布时间】:2016-09-17 09:26:20
【问题描述】:

当我尝试将视频添加到播放列表时出现错误

{“错误”:{“错误”:[{“域”:“youtube.playlistItem”,“原因”: “resourceIdRequired”,“消息”:“必需”}],“代码”:400, “消息”:“必需”} }

我的代码就是这样

<cfset jsonPlaylist={
  "snippet"= 
  {
    "playlistId"= "#form.ytPlaylist#",
    "resourceId"= 
    {
      "kind"= "youtube##video",
      "videoId"= "#YouTubeID#"
    }
  }
}>

<cfhttp result="assignplaylist" method="POST" url="https://www.googleapis.com/youtube/v3/playlistItems?part=snippet">
    <cfhttpparam type="header" value="Bearer #session.youTubeAuth.access_token#" name="Authorization">
    <cfhttpparam type="body" value="#serializeJSON(jsonPlaylist)#">
</cfhttp>

如果我转储 jsonPlaylist 我会得到

{"sn-p":{"resourceId":{"kind":"youtube#video","videoId":"xxxxxxxxx"},"playlistId":"xxxxxxxxxx"}}

如果我在此处将其粘贴到 API Explorer https://developers.google.com/youtube/v3/docs/playlistItems/insert#try-it

它工作正常。

有什么建议吗?谢谢

【问题讨论】:

    标签: coldfusion youtube oauth-2.0 youtube-api youtube-data-api


    【解决方案1】:

    我的 http 请求中缺少以下行。

    &lt;cfhttpparam type="header" value="application/json; charset=UTF-8" name="Content-Type"&gt;

    【讨论】:

      猜你喜欢
      • 2013-09-20
      • 2015-08-18
      • 2021-03-24
      • 2014-07-02
      • 2018-06-11
      • 2015-06-30
      • 2013-04-18
      • 2020-10-30
      • 2018-07-15
      相关资源
      最近更新 更多