Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResumableUpload discards response on 400 Bad Request #421

Closed
GoogleCodeExporter opened this issue Apr 14, 2015 · 5 comments
Closed

ResumableUpload discards response on 400 Bad Request #421

GoogleCodeExporter opened this issue Apr 14, 2015 · 5 comments
Assignees

Comments

@GoogleCodeExporter
Copy link

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

@ryanwilliams83
Copy link

bump, I opened this issue 2 years ago.

Non-Success error codes are returned by the YouTube API https://developers.google.com/youtube/v3/docs/errors

HttpResponseMessage.EnsureSuccessStatusCode() throws a HttpRequestException

ResumableUpload.cs calls EnsureSuccessStatusCode
https://github.com/google/google-api-dotnet-client/blob/d78d382ea7bdf2ea553e444d13611c66594098f4/Src/GoogleApis/Apis/%5BMedia%5D/Upload/ResumableUpload.cs

The HTTP Response Body can no longer be accessed once the HttpRequestException is thrown.

So developers do not have access to the error message that the YouTube API returns.

@peleyal
Copy link
Collaborator

peleyal commented Jun 22, 2015

Sorry that we didn't get to it until now... we are swamped :(

Do you want to create a pull request and attach the change?
https://developers.google.com/api-client-library/dotnet/contribute

We are going to have a new release in the next 2 weeks, so you will be able to contribute and solve the issue.

@chrsmith
Copy link
Contributor

chrsmith commented Jun 4, 2016

Closing this issue out as stale. If this is still a problem, please open a new issue with a small repro of the problem.

@chrsmith chrsmith closed this as completed Jun 4, 2016
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 6, 2020
@jskeet jskeet removed 🚨 This issue needs some love. triage me I really want to be triaged. labels Feb 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants