duannao8450 2016-05-31 14:47
浏览 96
已采纳

http.Client拒绝具有>不支持的协议方案“” <的请求,即使已设置

I try to upload some videos to youtube. Somewhere in the stack it comes down to a http.Client. This part somehow behaves weird.

The request and everything is created inside the youtube package.

After doing my request in the end it fails with:

Error uploading video: Post https://www.googleapis.com/upload/youtube/v3/videos?alt=json&part=snippet%2Cstatus&uploadType=multipart: Post : unsupported protocol scheme ""

I debugged the library a bit and printed the URL.Scheme content. As a string the result is https and in []byte [104 116 116 112 115]

https://golang.org/src/net/http/transport.go on line 288 is the location where the error is thrown.

https://godoc.org/google.golang.org/api/youtube/v3 the library I use

My code where I prepare/upload the video:

//create video struct which holds info about the video
video := &yt3.Video{
//TODO: set all required video info
}

//create the insert call
insertCall := service.Videos.Insert("snippet,status", video)

//attach media data to the call
insertCall = insertCall.Media(tmp, googleapi.ChunkSize(1*1024*1024)) //1MB chunk

video, err = insertCall.Do()
if err != nil {
    log.Printf("Error uploading video: %v", err)
    return
    //return errgo.Notef(err, "Failed to upload to youtube")
}

So I have not idea why the schema check fails.

  • 写回答

1条回答 默认 最新

  • dongmao3131 2016-05-31 17:29
    关注

    Ok, I figured it out. The problem was not the call to YouTube itself.

    The library tried to refresh the token in the background but there was something wrong with the TokenURL.

    Ensuring there is a valid URL fixed the problem.

    A nicer error message would have helped a lot, but well...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python