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

Why does the HipChat webhook generate invalid JSON?


When enabling the webhook to post the WebHookRequest to my API I am able to see the request. However when I want to parse this json request into a local object it fails since the JSON value contains semicolons.

An example of a request sent from HipChat to my API:

{ "event": "room_message", "item": { "message": { "date": "2015-07-09T16:06:52.039929+02:00", "from": { "id": 116, "links": { "self": ""; }, "mention_name": "JosKrause", "name": "Jos Krause" }, "id": "xxxxxxxxx", "mentions": [], "message": "/jira create test", "type": "message" }, "room": { "id": 98, "links": { "participants": "";, "self": "";, "webhooks": ""; }, "name": "HipChat Plugin TestLab" } }, "oauth_client_id": "xxxxxxxxx", "webhook_id": 7 }

As you can see after the URL values a semicolon is appended after the string value has been closed off.

This is completely preventing me from using the webhook.

Could you tell me what is going on please?

3 answers

1 accepted

2 votes
Answer accepted

I am directly returning the parameter containing the JSON body as the result of the POST call.

public HttpResponseMessage MyMethod(object json) {
    return new HttpResponseMessage("OK", json);

So that should copy it back as-is.

As per suggestion I have created an interface ( IHipChatRequest ) that resembles the properties available on the JSON-object and after casting it seems to resolve all properties fine and makes the semi-colon issue to disappear:

public HttpResponseMessage MyMethod([FromBody]IHipChatRequest json) {
    return new HttpResponseMessage("OK", json);

I am not sure why the "raw" json contains that semi-colon and why it disappears after the [FromBody] cast to the interface, I am going to accept it's part of the educational process implementing this webhook; after all I don't have to understand everything in order to create something I do understand =]

Many thanks though for thinking along and providing helpful feedback!

0 votes
Anatoli Atlassian Team Jul 09, 2015

Thanks for raising it Jos. While we are investigating the problem you can run a s/";/" substitution on json string before creating a json object.

0 votes
Conor Atlassian Team Jul 09, 2015


I was unable to reproduce this behaviour. The json sent to my webhook does not contain any semi-colons and looks fine:

{"event": "room_message", "item": {"message": {"date": "2015-07-10T00:24:58.419157+00:00", "from": {"id": 1, "links": {"self": ""}, "mention_name": "Conor", "name": "Conor"}, "id": "7bd37557-a4d6-49f5-b43b-c852901f23eb", "mentions": [], "message": "test", "type": "message"}, "room": {"id": 1, "links": {"participants": "", "self": "", "webhooks": ""}, "name": "Atlassian"}}, "oauth_client_id": "xxxxxxxxxxx", "webhook_id": 2}

Could you give me some additional information on your setup? What is implementing your API?


I am using WebAPI 2.1 using C#; I am returning the posted object as a HttpResponseMessage so I can see what information is exactly being sent to the post method.

I am also using the JSON.NET v7 library to parse and produce the JSON itself.

Conor Atlassian Team Jul 12, 2015

Thanks Jos. I'm not personally familiar with the C# stack. It would be good to verify the json at the wire level before it enters your server. One possibility would be to run a small local logging proxy and see what is going to and from your code. Alternatively the workaround that Anatoli mentioned may be sufficient to get you up and running.

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

35,256 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