Technologies:
Tolerim
a month ago
When sending multiple messages, the Pushullet API reports an error 500.
sendSms: async function (iden, numero, smsBody) {
let authHeaders = new Headers();
var body = {"data":{}};
if ((iden.length === 0) || (numero.length === 0) || (smsBody.length === 0)) {
console.warn("SMS SEND NOT VALID " + iden + ' ' + numero + ' ' + smsBody)
return;
}
authHeaders.append('Content-Type', 'application/json');
authHeaders.append('Access-Token', APIkey);
body.data.targetdeviceiden = iden;
body.data.addresses = [];
body.data.addresses.push(numero);
body.data.message = smsBody;
console.log(JSON.stringify(body));
let response = await fetch('https://api.pushbullet.com/v2/texts', {
method: 'POST',
headers: authHeaders,
body: JSON.stringify(body)
});
return;
}
Answers(2)
Vogi
a month ago
Verified Answer
The error message you are seeing is a server error, not a client error. Generally speaking, 5xx response codes indicate non-programmatic failures, such as a database connection failure, or some other system/library dependency failure. In many cases, it is expected that the client can re-submit the same request in the future and expect it to be successful.
It is possible that you are sending too many messages at once. According to Android Police, free accounts will be limited to 500 API pushes per month starting August 1st, 2016. However, this only applies to custom apps and services that use the Pushbullet public API. It won't affect Channels, IFTTT, manual pushes, and so on.
I hope this helps! Let me know if you have any other questions.
Sources
REST API error code 500 handling - Stack OverflowPushbullet will limit API-based pushes to 500 per month on free ...Pushullet API: error 500 when sending multiple messagesPushbullet APIPushbullet APITolerim
a month ago
The POST https://api.pushbullet.com/v2/texts 500 error indicates that there was a problem on the server-side of the Pushbullet API. It is not caused by the number of messages you are sending. To solve this issue, you could try to send smaller batches of messages at a time or contact the Pushbullet support team for assistance.
Regarding the code you provided, it appears to be correctly formatting the request and sending it to the Pushbullet API. However, you might want to add some error handling in case the API returns an error status code. You could also consider using a JavaScript library like Axios or Fetch to simplify the AJAX request.