halcy / Mastodon.py

Python wrapper for the Mastodon ( https://github.com/mastodon/mastodon/ ) API.
MIT License
876 stars 150 forks source link

Can't remove header image from profile #345

Open jeancf opened 1 year ago

jeancf commented 1 year ago

I can't figure out out to remove the header image from a profile. I could not find anything in the documentation about it.

I tried using

Mastodon.account_update_credentials(header=None)

but it does nothing (BTW, ChatGPT is positive that this is the way to do it).

I also tried

Mastodon.account_update_credentials(header="")

But this throws an exception "Could not determine mime type or data passed directly without mime type"

halcy commented 1 year ago

Honestly: Really good question. I don't know offhand how to do it. I'm at work right now, but I'll have a look at this once I get back home. Could be an oversight on my part, or an oversight on the mastodon side. The web UI uses an internal endpoint to delete the header that is not part of the API proper, POST-ing to "/settings/profile/pictures/header", the API docs for https://docs.joinmastodon.org/methods/accounts/#update_credentials don't specify a value that you might send as the new header to delete it.

I will mess around a bit later today to see if I can figure it out. Maybe it is possible to send a null value as multipart/form-data and that will make Mastodon do the intended thing, in which case I'd have to update the method to allow that type of thing, probably with a new parameter like "delete_header" / "delete_avatar".

jeancf commented 1 year ago

Hi there. Any luck with your attempt?

halcy commented 1 year ago

Hey - sorry, I got distracted working on other parts of the codebase, and now I am busy with working on something else entirely. I will look at this again when I get back to trying to build the next release of Mastodon.py, but probably it will take at least a month before i get back to this.

Anyone else is welcome to have a look in the meantime, obviously.

codl commented 1 year ago

This isn't currently possible, mastodon bug: https://github.com/mastodon/mastodon/issues/18921

codl commented 1 year ago

mastodon 4.2.0 now has DELETE /api/v1/profile/avatar and DELETE /api/v1/profile/header https://docs.joinmastodon.org/methods/profile/

jeancf commented 1 year ago

Excellent news! Thanks a lot.