Hi,
I am trying to post information from a file to a room but keep getting this error.
The request body cannot be parsed as valid JSON.
curl -H 'Content-Type: application/json' \ -d '{"color":"green","message": "'"$MESSAGE"'","notify":true,"message_format":"text"}'
Any idea why this would be happening ?
Thanks,
Victor
Hi VIctor,
$MESSAGE should be enclosed in {{"}} rather than {{'}}.
I use http://jsonlint.com/ to validate json, helps quite a bit.
Hi,
It's strange right now if I have
$MESSAGE = "TEST" it works fine, but if I have multi-line file it doesn't work.
Will try your solution of {{'}} for the text.
Thanks,
Victor
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It is " vs ' . You need to use ". I didn't format it correctly in my answer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I still can't get this work with a multi-line message, do you have an example of this working ? Or do I need to send the messages to HipChat one line at a time ?
Thanks,
Victor
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
New line is an invalid character in a JSON string. You need to substitute it with '\n' to have the new line inside a message.
E.g:
curl -d '{"color":"green","message":"My first notification \n (yey)","notify":false,"message_format":"text"}' -H 'Content-Type: application/json'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I am trying to take a html file that has list of files changes and send it to HipChat in a notification.
Is there a way we can have a call so you can help me with this.
I am getting the below error.
{ "error": { "code": 400, "message": "The request body cannot be parsed as valid JSON: Unterminated string starting at: line 1 column 28 (char 27)", "type": "Bad Request" }
Thanks,
Victor
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
New to hipchat... where do we create the curl commands? is that command line or within your programming language?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi VIctor,
$MESSAGE
should be enclosed in "
rather than '
.
I use http://jsonlint.com/ to validate json, helps quite a bit.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.