13

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.

2
  • did you try posting to http instead of https
    – Plato
    Commented May 31, 2016 at 15:34
  • @Plato yes I did, but with the same result
    – soupdiver
    Commented May 31, 2016 at 17:30

2 Answers 2

19

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...

1
  • 6
    I faced a similar issue where the request was malformed. One of the JSON fields was populated from config and the JSON field was empty since there was no value in the config. +1 on the nicer error message. Commented May 22, 2019 at 8:29
3

This will probably apply to very, very few who arrive here: but my problem was that a RoundTripper was overriding the Host field with an empty string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.