It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

HipChat Integration Plugin REST call

I need to make this REST call , that is provided from the HipChat integration plugin from my JIRA Plugin, specifically from the JAVA code:




In order to do that I wrote a Java class like so :


public class HCRoomCreate {
    private static final Logger log = Logger.getLogger(HCRoomCreate.class);
    private static String environment = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL);
    public static void createHipChatRoom(String issueKey) {
        String url = environment + "/rest/hipchat/compatibility/1.0/dedicatedroom";
        log.debug("URL configured for the REST Call is " + url);
        HttpClient httpClient = new HttpClient();
        String orig = "<username>:<password>";
        //encoding  byte array into  64
        byte[] encoded = Base64.encodeBase64(orig.getBytes());
        String sid  = new String(encoded);
       /* System.out.println("Original String: " + orig );*/
        System.out.println("Base64 Encoded String : " + new String(encoded));
        PostMethod post = new PostMethod(url);
        post.setRequestHeader("Content-Type", "application/json");
        post.setRequestHeader("Authorization", "Basic " + sid);
        //post.setRequestHeader("Authorization" ,"Bearer " + hipChatToken );
        //String payload = "{ \"name\": "+"\""+issueKey+"\"}";
        String payload = "{\n" +
                "                \"hipChatConfigured\": true,\n" +
                "                    \"projectKey\": \"<projectkey>\",\n" +
                "                    \"issueKey\": \""+issueKey+"\",\n" +
                "                    \"dedicatedRoom\": {\n" +
                "                        \"name\":  \""+issueKey+"\",\n" +
                "                        \"apiUrl\": \"https://<somevalidname>\",\n" +
                "                        \"privateRoom\": false\n" +
                "                    },\n" +
                "                \"hipChatUserName\": {},\n" +
                "                \"canCreateRoom\": true,\n" +
                "                    \"canAssignRoom\": true,\n" +
                "                    \"connectionStatus\": \"CONNECTED\",\n" +
                "                    \"userCanAccessPrivateRoom\": false,\n" +
                "                    \"hipChatLoginUrl\": \"\",\n" +
                "                    \"privateRoom\": false,\n" +
                "                    \"personalToken\": true,\n" +
                "                    \"jirauser\": true\n" +
                "            }";
        InputStream stream = new ByteArrayInputStream(payload.getBytes());
        //post.addParameter("name", issueKey);
        String responseBody = "";
        try {
            responseBody = post.getResponseBodyAsString();
        } catch (IOException e) {
            log.error("Fatal transport error " + e.getMessage());
        } finally {


But its giving me this error when this method call is invoked on issue creation:

 {"statusCode":403,"message":"You don't have enough permission or aren't logged in to HipChat to assign a dedicated room to this issue."}


The <username>/<password> in the above code is valid and I am able to login to JIRA with that, so technically since the HipChat integration plugin is already in the JIRA server, shouldnt the JIRA login credentials be enough?  Please advise.




1 answer

0 votes
Anatoli Atlassian Team Jan 07, 2016

Hi Yagnesh,

in order to be able to create a room inside HipChat a user needs HipChat's permission to do it. For example if you first click 'Create a [dedicated] room'  button in JIRA's interface we ask you to authorize against HipChat (using OAuth) and once we know that you are authorized we can create a room on your behalf.

You are getting a 403 response because the JIRA user you are making the call as has not yet been authorized against HC.

@Anatoli Kazatchkov , thanks for the reply. What I am trying to achieve is that when a user creates an jira ticket of a certain issuetype and certain severity, it should create a hipchat room on the fly with the name as the issue key. And also that room should be available under the "Dedicated Room" panel on the issue screen. Thats where I was leveraging the above mentioned dedicatedroom REST call , by calling it from the Java class I mentioned above. Do you know of a better way to acheive this?

Any updates @Anatoli Kazatchkov ? Please advise - I really need such kind of functionality in my plugin.

Anatoli Atlassian Team Jan 12, 2016

Yagnesh, it depends if you are writing a Connect add-on or if you are writing an old style add-on that runs within JIRA (i.e. P2). - For Connect add-ons you will need to prompt users to go through the OAuth Dance. You should do it inside your add-on UI, unfortunately there is no way to do it as a part of issue creation as far as I know. Once a user approved the access he/she would not need to do it again the next time. - If you are writing the old style P2 plugin you can access our API and use this methods to create dedicated room: UserService.getUser(String idOrEmail) RoomService.createRoom(String roomName, String ownerUserId, Option<String> topic, Option<Boolean> guestAccess, Option<String> privacy)

@Anatoli Kazatchkov , isnt there any proper way of authentication from the server side (Java) code itself so that I can make this call from the server side directly, using the code I provided?

Probably some additional parameters I can pass in the headers?

By the way, I am trying to make this call from a plugin written for a JIRA server, and not Cloud.

Anatoli Atlassian Team Jan 14, 2016

Yagnesh, the user on who's behalf you are making the call needs to log-in into HC. The user input is required if she hasn't authorised JIRA to act on her behalf yet.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Hipchat

Hipchat Cloud and Stride have reached End of Life (updated)

All good things come to an end - thanks to all our customers and partners who have been along the Hipchat and Stride journey with us.  As of Feb 15th 2019, Hipchat Cloud and Stride have reached ...

35,199 views 9 8
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you