Im trying to post message into Slack from external service with using "Incoming Webhooks", but it does not work.
For now , I got a error from developer console of Chrome which is 500 error. *The purpose of this coding is for chat app using slack.
Does anyone know how to post message into Slack?
var module = angular.module('myapp',[]);
module.controller("main", function($scope,$http){
$scope.users = [{"text":"message"},];
$scope.addUser = function(){
//push data into list "$scope.users" for debug
$scope.users.push({"text":$scope.txt});
$scope.text = "";
var successCallback = function(respose){
$scope.result = response.data;
$log.info(response);
};
var errorCallback = function(respose){
$scope.error = 'error';
};
var message = {
"text": $scope.txt,
"username":"",
"icon_url":"",
"icon_emoji":"",
"channel":"#XXX",
};
var configs = {
headers : {
'Content-Type': 'application/json'
}
};
$http({
method : "POST",
url : "https://hooks.slack.com/services/XXX/XXX/XXX",
payload : message,
config : configs
}).then(successCallback,errorCallback);
};
});