I was trying to use the REST API to cancel a pending notification that I sent to a single user also using the API (with include_player_ids
and a single recipient), however I can not do this without passing the REST API KEY, which should not happen, because in the manual it says in the conditions I am sending this was not necessary.
Am I doing something wrong or maybe it's a problem with the OneSignal's service? Here is the code:
//Creates the notification
$.post(
"https://onesignal.com/api/v1/notifications",
{
"app_id": appId,
"include_player_ids": [userId],
"send_after": later,
"template_id": templateId
},
function(data){
localStorage.ni = data.id;
}
);
//Cancel the notification
var notificationId = localStorage.ni;
$.get("https://onesignal.com/api/v1/notifications/"+notificationId+"?app_id="+appId);
Here is the response for the cancel request:
{
"errors":
[
"Please include a case-sensitive header of Authorization: Basic <YOUR-REST-API-KEY-HERE> with a valid REST API key."
],
"reference":
[
"https://documentation.onesignal.com/docs/accounts-and-keys#section-keys-ids"
]
}