Hello,
I am trying to send slack notifications using the HTTP method
public func sendSlackMessage() : async {
#Ok : Text;
#Err : Text;
} {
let host : Text = "hooks.slack.com";
// prepare system http_request call
let request_headers = [
{ name = "Host"; value = host # ":443" },
{ name = "User-Agent"; value = "http_weather_canister" },
{ name = "Content-Type"; value = "application/json" },
];
let url = "https://" # host # "/services/T02MG/BRMW/w6F5Dor";
Debug.print(url);
let body : JSON.JSON = #Object([
("text", #String("Danny Torrence left a 1 star review for your property."))
]);
let request : Types.CanisterHttpRequestArgs = {
url = url;
max_response_bytes = ?MAX_RESPONSE_BYTES;
headers = request_headers;
body = ?Blob.toArray(Text.encodeUtf8(JSON.show(body)));
method = #post;
transform = ?(#function(transform));
};
try {
Cycles.add(2_000_000_000);
let ic : Types.IC = actor ("aaaaa-aa");
let response : Types.CanisterHttpResponsePayload = await ic.http_request(request);
switch (Text.decodeUtf8(Blob.fromArray(response.body))) {
case null {
throw Error.reject("Remote response had no body.");
};
case (?body) {
#Ok(body);
};
};
} catch (err) {
#Err(Error.message(err));
};
};
while running this coded I am getting the following error message.
{
"Err": "Failed to connect: error trying to connect: tcp connect error: Network is unreachable (os error 101)"
}
Link for the candid : ICSCAN
Any idea why I am getting this error and how to resolve it?