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 use /code with API calls?

Within HipChat one can use "/code" to display code within the HipChat client. Is it possible to do this via the API? In my Python code, I wrapped my text around "<code>my super duper code</code>" but it doesn't display it like what one would see if I use the keyboard shortcut.

1 answer

0 votes
rich Atlassian Team Feb 24, 2016

Yes, this is possible through the send_message API. Here's an example:

curl -d '{"message":"/code your code goes here"}' -H 'Content-Type: application/json' https://api.hipchat.com/v2/room/&lt;room_id_or_name&gt;/message\?auth_token\=yourpersonaltokengoeshere

I'm using Python and I tried that as well but it didn't parse "/code" correctly.

hipchat_logger.log(20, "/code Hi I should be in a codeblock")

Output:

/code Hi I should be in a codeblock

 

 

rich Atlassian Team Feb 24, 2016

Are you sure you're using the send_message API and not the send_notification API?

Looking at the API, it looks like the author is using the "notification" endpoint.

rich Atlassian Team Feb 24, 2016

What library are you using? If possible, I'd avoid using a library and make the REST calls yourself.

Suggest an answer

Log in or Sign up to answer
TAGS
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,221 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