Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

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 votes
Syahrul Atlassian Team Jul 14, 2017

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 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 ...

36,034 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