Unable to create room

Aiyappa Ganesh July 5, 2017

I am trying to create a room using the HipChat API as soon as a user installs our add-on. However, I am now not able to create the room as I do not have the 'owner_user_id' which according to the documentation is not a mandatory field. Documentation says it defaults to the current user's id. But it still says 'Must be a valid room owner'.

How do I determine the user id of the user who installed the add-on? The installation data does not have the id of the user who installed the add-on.

1 answer

0 votes
crivers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 25, 2017

Hi Aiyappa, it sounds like you might need to provide an owner ID for the room when making the call from an add-on context. This is because there's no "current" user associated with the addon (as opposed to making the request using a personal API key, which does have a user associated with it).

I'd recommend using the User API to search for an appropriate user or keeping a cached value to be used as the owner ID of the rooms you're creating. Alternatively, you can probably retrieve the installer's user ID at install time and store it for later use.

Aiyappa Ganesh July 26, 2017

Hi Christopher,

Thank you for the insightful response! I did consider the suggestions. As any public HipChat team might want to install the add-on into their rooms, I would not have access to any of their users until they install my add-on and interact with it. So that option does not work for me if I want to create the room as soon as the add-on has been installed.

The alternative approach of retrieving the installer's user ID at install time is the route I would prefer taking. However, I do not see any user information in the installation data received at the installation callback.

Appreciate if you could provide steps on retrieving the installer's User ID.

crivers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 26, 2017

Hmm - glancing over the docs, I don't actually see a way to retreive the installing user, only the group ID (and potentially room ID). That might be a mistake on my part. In that case. In that case, as long as your addon has the proper scope, you could make a request to /v2/user to find a user to  with Title Expansion in order to find a group. 

I'll add this as an improvement request to our API team - it sounds like it could be something useful to have during installation time :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events