Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

push notifications in server code

I am calling a server code api to send a push message from an external site. It returns http 200 return code but it contains no response body and is not sending the push

If I test the server code in appery test system it functions correctly and returns "{"mail":"success"} in the body.

My server code is as follows:

pre
// Push Notifications API key from:
// Apps [App] Push Notifications Settings
// 'badge' is iOS only setting

var pushApiKey = "0813456a-4b56-4386-97a1-b3daacf5c3ee";
var body = JSON.parse(request.body());
var message = body.message;
console.log("body",body);
console.log("message = ",message);
Apperyio.PN.send(pushApiKey, {
payload: {
"message": message
}
});
Apperyio.response.success({"push":"success"}, "application/json");
/pre

My calling url is: https://api.appery.io/rest/1/code/272... and I am passing it a body of {"message":"this is a test"} as a POST.

I don't know how to return any debug info back to my site so that I can work out what is going on.

Please point me in the right direction

...Update...
Ok, Partially fixed, i found out from the trace logs that message was empty and that has been corrected. The call to the script does send the push message, but the response body is still empty. Why is this?

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

push notifications in server code

Hello Terry,

Could you send the same request with any REST client, e. g. Postman? Do you have the same results? Do you have any information in the trace tab?

Return to “Issues”