Hi,

I'm running into weird issues with httplib2 when following the instructions 
for resumable uploads to YouTube (see 
here: 
https://developers.google.com/youtube/v3/guides/using_resumable_upload_protocol).

Their very first server roundtrip creates a video resource and returns a 
"Location" response header, which is the upload URL to send the actual 
video file. That works well and when I invoke this service using cURL like 
so:

curl -X POST \
     --verbose \
     -H "Authorization: Bearer ..." \
     -H "Content-Type: application/json; charset=UTF-8" \
     -H "X-Upload-Content-Type: video/*" \
     -H "X-Upload-Content-Length: 500" \
     -d '{"snippet": {"title": "foo"}, "status": {"privacyStatus": 
"unlisted"}}' \
    
 
"https://www.googleapis.com/upload/youtube/v3/videos?uploadType=resumable&part=snippet%2Cstatus";

...it works as desired and gives me a HTTP/200 and the aforementioned 
"Location" response header. I tried to mimic that in a GAE Python app, 
using the httplib2 library. Here is what I do:

http = httplib2.Http()
credentials.authorize(http)
                    
body = simplejson.dumps({

'snippet': {

'title': 'foo',

'description': 'bar'

},

'status': {

'privacyStatus': 'unlisted'

}

})
                    
response, content = http.request(

uri = 
'https://www.googleapis.com/upload/youtube/v3/videos?uploadtype=resumable&part=snippet%2Cstatus'
, 

method = 'POST',

body = body, 

headers = {

'X-Upload-Content-Length': str(size),

'X-Upload-Content-Type': 'video/*',

'Content-Type': 'application/json; charset=UTF-8'

}

)


However, that request returns a HTTP/400 with a body that says:


{

 "error": {

  "errors": [

   {

    "domain": "global",

    "reason": "badContent",

    "message": "Media type 'application/json; charset=UTF-8' is not 
supported. Valid media types: [video/*, application/octet-stream]"

   }

  ],

  "code": 400,

  "message": "Media type 'application/json; charset=UTF-8' is not 
supported. Valid media types: [video/*, application/octet-stream]"

 }

}


That doesn't make any sense to me. Somehow, it confuses the "Content-Type" 
header with that "X-Upload-Content-Type" and I don't know why that is. I 
tried passing the HTTPS traffic through a HTTP proxy, but httplib2 does not 
seem to play nicely with the HTTP proxy I use (Charles). 


Ideas, anyone?


Thanks heaps,

Soeren

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/1720e68e-68e7-4406-9d52-a4041e758fbd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to