I have developed an app on parse.com
I have created following function to send SMS using plivo.
function sendRSVPSMS(PlivoNumber, GuestNumber, Message) {
var payLoad = {
src: PlivoNumber,
dst: GuestNumber,
text: Message
};
Parse.Cloud.httpRequest({
url: "<My Plivo URL>",
method: "POST",
body: payLoad,
success: function (httpResponse) {
console.log('httpRequest success');
response.success("Sent successfully");
},
error: function (httpResponse) {
console.log('SendSMS: Request failed');
response.error('Request failed');
}
});
}
What can be the reason?
May be You forgot to specify the header for content type.
"Content-Type": "application/json"
So your code will be as below
function sendRSVPSMS(PlivoNumber, GuestNumber, Message) {
var payLoad = {
src: PlivoNumber,
dst: GuestNumber,
text: Message
};
Parse.Cloud.httpRequest({
url: "<My Plivo URL>",
method: "POST",
body: payLoad,
headers: {
"Content-Type": "application/json"
},
success: function (httpResponse) {
console.log('httpRequest success');
response.success("Sent successfully");
},
error: function (httpResponse) {
console.log('SendSMS: Request failed');
response.error('Request failed');
}
});
}