http.Client rejects request with >unsupported protocol scheme ""< even if it's set


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 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] on line 288 is the location where the error is thrown. 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 errgo.Notef(err, "Failed to upload to youtube")

So I have not idea why the schema check fails.


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…

Answered By – soupdiver

Answer Checked By – Willingham (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.