Can I use the API to remove an avatar URL?
When I try to remove an avatar URL with the API, it ends up being the URL of the Canvas instance instead. Is there a way to remove the URL?
Upon further inspection, it appears the simple answer to your question "Is it possible through the API" is No.
Now that we know the solution isn't a simple typo, I looked at what was happening.
I'm able to duplicate the same behavior through the Advanced REST Client in Chrome, so it's not a cURL issue. If I send it with a blank value, it comes back with the main URL of the Canvas instance.
This happens with either application/x-www-form-urlencoded or application/json encoding, so it's not an encoding issue.
When I first pulled up a student who had no Avatar, they still had an avatar URL that pointed to a generic user Avatar. I was able to set it back to that, but not to a blank value.
I'd call that a bug, but I don't get to make those calls. Deleting an entry and setting it to an empty or null value are not the same thing.
Even inside Canvas, there are no Avatar management features that I can find. I can upload another one, but there aren't options to select a previously uploaded file or to delete files you've uploaded.
When you click the "Remove avatar picture" from the User Accounts page, it doesn't use the API. It uses an AJAX call with a PUT directive, but the location it's calling isn't through the API, it's under /images/users/4696 (the 4696 being the Canvas user Id). The payload it sends is avatar[state]=none, However, it also sends an authenticity_token and a page_view_id, which is presumably used to generate the authenticity_token.
I tried reusing a page_view_id and authenticity_code to remove another avatar and it did not work, so it appears that there is some security in place to make sure that people don't maliciously delete people's avatar images.
By the way, when I deleted my profile, it reset it to the default avatar-50.png user one.
But it looks like it is not possible through the API in its current form. You could make a feature request for it to allow for deleting the Avatar or call it a bug that it detects an empty string as a relative path.
Joshua, I'm not sure about the answer to your question (you lost me after the second sentence), but I'm going to share this with the Canvas Developers group to see if they can help.
I understood that the Avatar URL should be present if you have Avatar's enabled, but that it pointed to a default Avatar for each instance that is returned when there isn't one supplied. I even wrote a script that displayed a photo roster based on that avatar_url being there.
However, that being said, the default shouldn't be the instance of your organization. So, one of two things comes to mind. Either your default Avatar URL is set to your institutions Canvas instance (unlikely, but I won't rule it out) or the CURL command you're using is setting it to that.
When I look at the commands you posted, I noticed that there is nothing after the = except a space. That might be the issue. Have you tried using ="" (double empty quotes) to actually give the field a value? In the code below, you have line 1 and I'm suggesting line 2.
I haven't verified this, but that's where I'd start.
Using empty quotes gives the same result - avatar_url ends up being https://ucmerced.test.instructure.com.
But if I use "http://", then I get exactly that. Seems like the logic is "prepend my URL to the value unless it starts with http(s)://". Which leaves no way to set it back to empty.
Thanks! Looks like for now, I'll be using /images/messages/avatar-50.png for profiles that don't or should not have an avatar.