I am trying to send SMS from my mobile by using PushBullet API from Google Apps Calc script.
The script is (auth data redacted)
function send_SMS() {
Logger.log("send_SMS start");
var options = {
"method" : "post",
"Content-Type" : "application/json",
"headers" : { "Authorization": "Basic aaaaaaaaaaaaaaaaaa" },
"payload" : {
"push" : {
"type" : "messaging_extension_reply",
"package_name" : "com.pushbullet.android",
"source_user_iden" : "iiiiiiiiiiiii",
"target_device_iden" : "iiiiiiiiiiiiiiidddddddddd",
"conversation_iden" : "0999999999",
"message" : "TestSMS" },
"type" : "push"
}
};
var push_bullet_url = "https://api.pushbullet.com/v2/ephemerals";
Logger.log(options);
UrlFetchApp.fetch(push_bullet_url, options);
return;
}
I seem to be making some JSON packing error, as I get 400. "Failed to parse JSON body.”
The documentation is on https://docs.pushbullet.com/#send-sms
I tried CURL on Windows and command works without problems (one I did “”” escaping)
curl --header "Access-Token: ttttttttttttttt" --header "Content-Type: application/json" --data-binary "{ """push""": { """type""": """messaging_extension_reply""", """package_name""": """com.pushbullet.android""", """source_user_iden""": """iiiiiiiiiiiiiiii""", """target_device_iden""": """iiiiiiiiiiiiiiiiiddddddddddddd""", """conversation_iden""": """0999999999""", """message""": """TestSMS""" }, """type""": """push"""}" --request POST https://api.pushbullet.com/v2/ephemerals
I successfully wrote Google Apps scripts to get user_ident, device_ident and to send test “note” message. I think that the problem might be due to proper formatting of string quotes in JSON payload in the script.