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

411 error from mark_as_spam and set_moderation_status in youtube api #358

Open
rparrett opened this issue Sep 14, 2022 · 3 comments
Open

Comments

@rparrett
Copy link

Tested version v4.0.1+20220303

if spam.len() > 0 {
    let result = hub.comments().mark_as_spam(&spam).doit().await;
    if result.is_err() {
        println!("{:?}", result);
    }

    let result = hub
        .comments()
        .set_moderation_status(&spam, "rejected")
        .ban_author(true)
        .doit()
        .await;
    if result.is_err() {
        println!("{:?}", result);
    }
}

Both of these calls are failing with HTTP 401 Length Required.

@Byron
Copy link
Owner

Byron commented Sep 15, 2022

In order to make this fixable, it would be required to figure out how this call should look like possibly by referring to the original google docs for that API or intercepting a working request.

From there it might be possible to adjust the generator to deal with this - per API overrides or special cases are possibly by design. In any case, this will need to be contributed. Thanks for your understanding.

@rparrett
Copy link
Author

Hi, thanks for the response. I understand.

Unfortunately, I'm running into some deeply mysterious python errors attempting to build this thing, and I've found a workaround, so I likely won't be motivated to contribute a fix.

I will dump the information here though, in case it helps someone else.

Adding .header(CONTENT_LENGTH, 0); to the generated code for the request builder for these API calls fixes the issue. This likely needs to be done for any POST request with an empty body though, and I'm not sure what the best way to accomplish that is.

However, you can sidestep the issue by configuring your HttpsConnectionBuilder to exclusively use http2, like so:

    let https = hyper_rustls::HttpsConnectorBuilder::new()
        .with_native_roots()
        .https_only()
        .enable_http2()
        .build();

@Byron Byron removed the question label Sep 16, 2022
@Byron
Copy link
Owner

Byron commented Sep 16, 2022

Great, thanks for your help!

It seems that setting the content length should be very possible for the generator to do, and let me CC @kylegentle who has been helping a lot recently and might be in the position to make this improvement at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants