Failing to change avatar using Discourse API

I have an API key that has “Global” access, for “All Users”.

I do this:

$updateAvatarUrl = sprintf("%s/u/%s/preferences/avatar/pick.json", $this->apiHost, $username);
$headers = array(
    "Api-Key: ".$this->apiKey,
    "Api-Username: ".$this->apiUsername
$data = array(
    'upload_id' => $uploadId,
    'type' => 'uploaded'
$response = Q_Utils::put($updateAvatarUrl, $data, null, null, $headers);

But the result I get back is:


I tried also sending it as application/json. Here is the full CURL info:

$url = '';

"User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (K HTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36"
"Content-Type: application/x-www-form-urlencoded"
"Content-Length: 28"
"Api-Key: 3cf975095fd50e22e3631dc916c6d2c7694419ed421338dd7bba432ba1e71417"
"Api-Username: system"



You can see that Profile - fdhsjkgfs_dghjkl - Intercoin exists.

The upload ID indeed exists too, this is what I get after I do the upload:

  "id": 2159,
  "url": "",
  "original_filename": "400.png",
  "filesize": 20636,
  "width": 360,
  "height": 360,
  "thumbnail_width": 360,
  "thumbnail_height": 360,
  "extension": "png",
  "short_url": "upload://trIsPeqspDPRwbMsOnjtDCBBMwK.png",
  "short_path": "/uploads/short-url/trIsPeqspDPRwbMsOnjtDCBBMwK.png",
  "retain_hours": null,
  "human_filesize": "20.2 KB"

So what is the problem? I followed what the docs say…

1 Like

And also, for some reason, the links in the description and website are not clickable after I set them using CURL:

But on other summary boxes, they are. With the same URLs.

What am I doing wrong, there?

        Q_Utils::put($this->apiHost."/u/$username.json", array(
            'title' => 'Forum Engagement Bot',
            'bio_raw' => 'Powered by',
            'website' => ''
        ), null, null, $headers);
1 Like

And finally … is there any way in forum control panel to make the summary boxes appear fully to the public (with bio, website, etc.) rather than just with limited info?

Maybe that’s because these users reached trust level 1. To prevent spam, the links of new users do not work.

Is it possible to set trust level of a user via API?

I just searched here and found

So it seems possible.


By the way, the answer to the original question was that “SSO overrides avatar” was turned on. Turning it off solved the problem.

I was also able to successfully upgrade the trust level via the API and this causes the full summary box to appear. Thanks, fam!