liuqiaosz / google-api-dotnet-client

Automatically exported from code.google.com/p/google-api-dotnet-client
Apache License 2.0
0 stars 0 forks source link

ResumableUpload discards response on 400 Bad Request #421

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Problem:
Unable to access JSON formatted API response when uploading to YouTube using 
InsertMediaRequest class if the YouTube API returns a 400 Bad Request

Cause:
ResumableUpload.InitializeUpload(CancellationToken cancellationToken)
makes a call to HttpWebRequest.EnsureSuccessStatusCode()

According to the documentation HttpWebRequest.EnsureSuccessStatusCode() 
disposes of the response stream.

Suggestion:
Edit ResumableUpload.InitializeUpload(CancellationToken cancellationToken)
Manually check request.IsSuccessStatusCode and if it's false throw a custom 
HttpRequestException including the response from the API.

Original issue reported on code.google.com by CableGuy...@gmail.com on 2 Dec 2013 at 2:53

GoogleCodeExporter commented 9 years ago
Oops, I meant check response.IsSuccessStatusCode 

Original comment by CableGuy...@gmail.com on 2 Dec 2013 at 2:57

GoogleCodeExporter commented 9 years ago

Original comment by pele...@google.com on 20 Dec 2013 at 2:03