I am fairly new to zway. With this said, I am trying to do a HTTP request to a mail service that uses a REST API. I tested a request earlier using AJAX (I know AJAX is client side but it let me know that I am in the right general direction) and it worked fine. However, I cannot get it to work in my function.
Code: Select all
zway.devices[2].instances[0].SensorBinary.data[1].level.bind(function () {
if (this.value === true) {
http.request({
url: "https://mandrillapp.com/api/1.0/messages/send.json",
method: "POST",
data: {
"key": "aKeyThatWorksInAJAX",
"message": {
"text": "A Message to Send",
"subject": "A Subject",
"from_email": "AnEmail",
"from_name": "Person",
"to": [{
"email": "Test",
"name": "User"
}]
}
}
});
}
});
Code: Select all
$.ajax({
type: "POST",
url: "https://mandrillapp.com/api/1.0/messages/send.json",
data: {
"key": "AKeyThatWorks",
"message": {
"text": "Test",
"subject": "I need Help",
"from_email": "anEmail@live.com",
"from_name": "APerson",
"to": [{
"email": "anEmail@hotmail.com",
"name": "User"
}]
}
}
});