How to share file with room in HipChat via Postman or Jersey client?

How to share file with room in HipChat via Postman or Jersey client? Please provide the solution for this. I tried with below link but unable to share the file, please can you help me on this. In below link if Hipchat provide any example its good to developers. 

I included screen shots, which I tried from postman.

Note:  I used API access token with send message scope.

I am getting below error:

"error": {
"code": 400,
"message": "No file was found in the request. See for an example",
"type": "Bad Request"

10-Jul-17 7-43-33 PM.jpg10-Jul-17 7-44-01 PM.jpg

Thanks in advance 

1 answer

0 vote

Hi Prantish,


I'm not that good with the Postman, but if you are looking for a way to upload a file, I would suggest you try this python script:

#!/usr/bin/env python

from __future__ import print_function
import requests
import sys
import json
import os

def hipchat_file(token, room, filepath, message='', host=''):
""" Send file to a HipChat room via API version 2
token : str
HipChat API version 2 compatible token - must be token for active user
room: str
Name or API ID of the room to notify
filepath: str
Full path of file to be sent
message: str, optional
Message to send to room
host: str, optional
Host to connect to, defaults to

if not os.path.isfile(filepath):
raise ValueError("File '{0}' does not exist".format(filepath))
if len(message) > 1000:
raise ValueError('Message too long')

url = "https://{0}/v2/room/{1}/share/file".format(host, room)
headers = {'Content-type': 'multipart/related; boundary=boundary123456'}
headers['Authorization'] = "Bearer " + token
msg = json.dumps({'message': message})

payload = """\
Content-Type: application/json; charset=UTF-8
Content-Disposition: attachment; name="metadata"
Content-Disposition: attachment; name="file"; filename="{1}"
""".format(msg, os.path.basename(filepath), open(filepath, 'rb').read())

r =, headers=headers, data=payload)

my_token = 'token'
my_room = 'room id'
my_file = '/Users/syahrul/Desktop/file.csv'
my_message = 'Check out this cool file' # optional

hipchat_file(my_token, my_room, my_file, my_message)
except Exception as e:
msg = "[ERROR] HipChat file failed: '{0}'".format(e)
print(msg, file=sys.stderr)

Just change the my_token to your APIv2 token and my_file to your file path location. Also, you can tweak the my_message to your message when sending the file.


Hope this helps.



Is there a way to do this in Java ?

I'm having an issue with it. See below. 

String file_path = "src/test/resources/sku/";

File file = new File(file_path);

 // JSONObject message = new JSONObject();

// message.put("message", "sku_uploads");

 FileBody fileBody = new FileBody(file);

MultipartEntityBuilder builder = MultipartEntityBuilder.create().addPart("file", fileBody);

builder.addBinaryBody("file", file, ContentType.create("application/zip") , "");

HttpEntity multiPartEntity =;

String boundary = "===" + System.currentTimeMillis() + "===";

// execute post and parse response data

httpPost = new HttpPost("https://${host}/v2/room/${room_name}/share/file");

httpPost.setHeader(HttpHeaders.AUTHORIZATION, "Bearer ${token}");

//httpPost.setEntity(new StringEntity(message.toString(), "UTF-8"));



httpPost.addHeader("Content-Type", "multipart/related; boundary="+ boundary);

// httpPost.addHeader("Content-Type", "application/json");

httpPost.addHeader("charset", "UTF-8");

handler = new BasicResponseHandler();



response = httpClient.execute(httpPost);

String body = EntityUtils.toString(response.getEntity(), "UTF-8");







Error message :


  "error": {

    "code": 400,

    "message": "No file was found in the request. See for an example",

    "type": "Bad Request"



Suggest an answer

Log in or Join to answer
Community showcase
Maarten Cautreels
Published Oct 07, 2017 in Hipchat

Bringing Structure to your HipChat Instance

...have mention name FirstnameLastname. Fe.: @MaartenCautreels This certainly helps to know who is being mentioned in a conversation. Imagine your colleague sends the following message...

467 views 1 4
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot