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 vote

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';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")


/code Hi I should be in a codeblock



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.

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