I'm creating a few simple Bot functions to create threads and send messages to Chat. Creating 'arbitrary' threads and inserting messages into threads with known ids is fine, no problem, I am simply not able to specify the thread id when creating a new one. I've followed details in the Google documentation but can't get any of them to work.
See: https://developers.google.com/hangouts/chat/how-tos/bots-develop
This is my code - very straightforward, but obfuscated
$("#fa-comment").click(function() {
$.ajax({
method: 'POST',
url: 'https://chat.googleapis.com/v1/spaces/SPACE_ID/messages?key=KEY_ID&token=TOKEN_ID',
dataType: "json",
contentType: "application/json; charset=UTF-8",
//data: "{'text':'This creates a new thread and inserts message - thread id is not known'}",
//data: "{'text':'This inserts into a current thread with known id', 'thread':{'name':'spaces/SPACE_ID/threads/THREAD_ID'}}",
success: function () {
$('.response').html('Success');
}
});
})
Both of the commented out data:
lines work perfectly.
I have tried:
data: "{'text':'This inserts into a new thread with specified id', 'thread':{'name':'spaces/SPACE_ID/threads/SPECIFIED_THREAD_ID'}}",
but that results in a 500 errorhttps://chat.googleapis.com/v1/spaces/SPACE_ID/messages?\ threadKey=ARBITRARY_STRING
as written in the documentation but no variation works - get 400 errors and violations/unknown variable 'threadkey'
I've followed every which way I can from the documentation and trying variations but to no avail.
There is undoubtedly something I have missed here but I can't see it. Any help for this would enable my hair to grow again!