Microsoft Teams Post Message
Post a message to Microsoft Teams with a specified text.
2020-01-10 (C) Questetra, Inc. (MIT License)
Configs
  • A: Endpoint URL *
  • B: Select TEXT DATA for Title
  • C: Select TEXT DATA for Text *
  • X: Select TEXT DATA for Log
Script
//// == Config Retrieving ==
var endpointUrl = configs.get("conf_EndpointUrl") + "";

//// == Data Retrieving ==
var dataNum_Title = configs.get("conf_Title") + "";
var title = "";
if (dataNum_Title !== "") {
  title = engine.findDataByNumber( configs.get("conf_Title") ) + "";
}
var text = engine.findDataByNumber( configs.get("conf_Text") ) + "";

//// == Calculating ==
var uri = endpointUrl;

var requestObj = {
  "title": "",
  "text": ""
};
requestObj.title = title;
requestObj.text = text;

var response = httpClient.begin()
  .body( JSON.stringify( requestObj ), "application/json")
  .post( uri );

//// == Data Updating ==
//If log data is specified
var dataNum_Log = configs.get("conf_Log") + "";
if (dataNum_Log !== "") {
  var log = "";
  log += "---POST request--- " + response.getStatusCode() + "\n";
  log += response.getResponseAsString() + "\n";
  engine.setDataByNumber( dataNum_Log, log );
}

Download

Capture

See also

%d bloggers like this: