HipChat API question - send private message

852 views
Skip to first unread message

Yves Berquin

unread,
Jan 29, 2015, 9:52:25 AM1/29/15
to atlassian-...@googlegroups.com
I've been asking around and it seems this is the place to ask questions about the HipChat API.
Please redirect me if this is not the case.

I am trying to send a simple private message with the REST API v2 as described here:
https://www.hipchat.com/docs/apiv2/method/private_message_user

If I try sending the message text as the post payload, with a "text/plain" mime type, it's working.

What I don't understand is how to send the additional parameters.
I tried:
  • sending all the parameters as "form" parameters with the "application/x-www-form-urlencoded" mime type
  • sending a single json object, with the "application/json" mime type
In both case I receive in the message the whole content, including all the POST delimiters in the first case, and all the json format characters verbatim,  in the 2nd case.

The Java library doesn't include that API, so I can't steal from that code.

The only explanation regarding formatting in that page tells me "The message can also be sent as text/plain". Also? With reference to what?

Thanks for any explanations you may add to that API page to clarify it.
By the way, I think the default for notify should be true in that explanation (with my simple text method, it does notify).

Yves

Seb Ruiz

unread,
Jan 29, 2015, 7:58:38 PM1/29/15
to atlassian-...@googlegroups.com

Hi Yves,

The following worked for me:

curl -d '{"message": "Surfs up (awyeah)", "notify": false, "message_format": "text"}' -H 'Content-Type: application/json' "https://api.hipchat.com/v2/user/<user>/message?auth_token=<token>" 

i.e - you need to set Content-Type to application/json and send the payload in the bodye.

Inline images 1

--
You received this message because you are subscribed to the Google Groups "Atlassian Connect Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to atlassian-connec...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Seb Ruiz
Atlassian

Yves Berquin

unread,
Jan 30, 2015, 6:08:08 AM1/30/15
to atlassian-...@googlegroups.com
Thanks Seb.

This works indeed - I was having an issue with my client code.

Your example also taught me that you can use api.hipchat.com whatever the custom hipchat domain is. Didn't understood that before.

Yves


On Friday, January 30, 2015 at 1:58:38 AM UTC+1, Seb Ruiz wrote:

Hi Yves,

The following worked for me:

curl -d '{"message": "Surfs up (awyeah)", "notify": false, "message_format": "text"}' -H 'Content-Type: application/json' "https://api.hipchat.com/v2/user/<user>/message?auth_token=<token>" 

i.e - you need to set Content-Type to application/json and send the payload in the bodye.

Inline images 1

On 30 January 2015 at 01:52, Yves Berquin <yves.b...@gmail.com> wrote:
I've been asking around and it seems this is the place to ask questions about the HipChat API.
Please redirect me if this is not the case.

I am trying to send a simple private message with the REST API v2 as described here:
https://www.hipchat.com/docs/apiv2/method/private_message_user

If I try sending the message text as the post payload, with a "text/plain" mime type, it's working.

What I don't understand is how to send the additional parameters.
I tried:
  • sending all the parameters as "form" parameters with the "application/x-www-form-urlencoded" mime type
  • sending a single json object, with the "application/json" mime type
In both case I receive in the message the whole content, including all the POST delimiters in the first case, and all the json format characters verbatim,  in the 2nd case.

The Java library doesn't include that API, so I can't steal from that code.

The only explanation regarding formatting in that page tells me "The message can also be sent as text/plain". Also? With reference to what?

Thanks for any explanations you may add to that API page to clarify it.
By the way, I think the default for notify should be true in that explanation (with my simple text method, it does notify).

Yves




--
Seb Ruiz
Atlassian

Peter Brownlow

unread,
Feb 1, 2015, 7:28:47 PM2/1/15
to atlassian-...@googlegroups.com
Hi Yves,

Using api.hipchat.com works (and is simple and reliable) for HipChat Cloud but not HipChat Server. Just something to be aware of if you wish to be compatible with Server.

-Peter
Reply all
Reply to author
Forward
0 new messages