尝试将视频添加到播放列表时,出现错误
{ "error": { "errors": [ { "domain": "youtube.playlistItem", "reason": "resourceIdRequired", "message": "Required" } ], "code": 400, "message": "Required" } }
我的代码就是这样
<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 我得到
{"snippet":{"resourceId":{"kind":"youtube#video","videoId":"xxxxxxxxx"},"playlistId":"xxxxxxxxxx"}}
如果我将其粘贴到API资源管理器中https://developers.google.com/youtube/v3/docs/playlistItems/insert#try-it
它可以正常工作。
有什么建议么?谢谢
最佳答案
我的http请求中缺少以下行。<cfhttpparam type="header" value="application/json; charset=UTF-8" name="Content-Type">
关于coldfusion - YouTube V3 API播放列表项resourceIdRequired,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37341171/