Skip to content

Instantly share code, notes, and snippets.

@aspyker
Created January 27, 2016 21:55
Show Gist options
  • Save aspyker/6760310d5061a8beb5a2 to your computer and use it in GitHub Desktop.
Save aspyker/6760310d5061a8beb5a2 to your computer and use it in GitHub Desktop.
Updating Hipchat's room avatars
Note: I wasn't (yet) able to get this to work, but adding here so maybe someone else gets further:
- get your host name for the API .. something like COMPANYNAME.hipchat.com
- create an oauth token for your user through the hipchat web UI, lets say it is OAUTHKEY with all permissions
- find an image you want to use for your room avatar and get the base64 encoded version using a tool like:
https://www.base64-image.de/
- save the image to with the below contents, let's say as avatar.json:
{ "avatar" : "base64encodinghere" }
- curl -v http://COMPANYNAME.hipchat.com/v2/room/ROOMNAME?auth_token=OAUTHKEY"
- you should get a json file that is the description of the room currently, and it shouldn't have a avatar_url field
- curl -v -H "Content-Type: application/json" -X PUT --data @avatar.json "http://COMPANYNAME.hipchat.com/v2/room/ROOMNAME/avatar?auth_token=OAUTHKEY"
- you should get a 204 response
- curl -v http://COMPANYNAME.hipchat.com/v2/room/ROOMNAME?auth_token=OAUTHKEY"
- you should now see a avatar_url": "uploads.hipchat.com/photos/room_XXXXX/XXXXXX.png"
Now, if you look at that url, the image does exist. However, neither the web client nor macos client shows it in the UI.
@sigmasoldi3r
Copy link

sigmasoldi3r commented Sep 27, 2016

Seems that we have to provide that descriptor, it gives me the following error (But seems near to be done!):

curl : { "error": { "code": 403, "message": "This action requires one of the following scopes: [u'view_group',
u'view_room']", "type": "Forbidden" } }
En línea: 1 Carácter: 1
+ curl -v https://argochamber.hipchat.com/v2/room/3138969?auth_token=cN ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
   eption
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Note that I'm using curl with Window's PowerShell, maybe under Linux works 💻

How nice would be to change Hipchat room's avatar. 💥 🌝

@andrewleith
Copy link

I managed to get this working by executing the following:

curl -v -H "Content-Type: application/json" -X PUT -d '{ "avatar": "BASE64 Encoded Image here" }' http://SERVER_NAME_HERE.hipchat.com/v2/room/ROOM_NAME_HERE/avatar?auth_token=AUTH_TOKEN_HERE

I can verify that the image is there using GET /avatar (it returns a URL on amazon S3), but still, the image doesnt show up in the app (web, or desktop). Seems rather pointless.

@djkotowski
Copy link

I'm having the same issue as @andrewleith. I've confirmed the upload worked, but it doesn't appear anywhere.

@d0nn13
Copy link

d0nn13 commented Jan 19, 2017

Same here, upload (and rescaling by server) succeeds, but UIs (webapp, MacOS) do not display it.

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