Skip to content

400 bad request with media and media_with_thumbnail methods #6

Closed
@ckruse

Description

Hi there,

when trying to upload a picture with the media request I get a 400 bad request response. Doesn't matter if I post to my local test installation or an publicly available Mastodon instance.

Creating a status w/o medium works.

This is my code:

    let toml_path = env::var("MASTODON_TOML").expect("env variable MASTODON_TOML not set");
    let mastodon = Mastodon::from(toml::from_file(toml_path).unwrap());

    let path = format!(
        "{}/{}/original/{}",
        image_base_path(),
        picture.id,
        picture.image_file_name
    );

    let thumbnail_path = format!(
        "{}/{}/thumbnail/{}",
        image_base_path(),
        picture.id,
        picture.image_file_name
    );

    let attachment = mastodon
        .media_with_thumbnail(path, thumbnail_path, picture.alt.clone())
        .await
        .map_err(|e| {
            println!("Error uploading media: {}", e);
            e
        })?;

That produces this error message:

Error uploading media: Api { status: 400, response: ApiError { error: "Bad Request", error_description: None } }

Am I doing something wrong or is this a bug in the library?

Best regards,
CK

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions