Hey Soeren, Given that the issue only occurs on GAE while the equivalent HTTP using CURL is valid, this appears to be an issue in the infrastructure. Normally such a report should go in the public issue tracker, but I've handled the issue by reproducing what you saw. We're now working on diagnosing a fix or workaround, and I hope to report back soon with an update.
Sincerely, Nick On Tuesday, September 1, 2015 at 1:03:52 AM UTC-4, Soeren Balko wrote: > > 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/ee86422e-d0bb-4629-a3bf-c49ade77e545%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
