[OpenSIPS-Users] SIP Push Notification

Prathibha B prathibhab.tvm at gmail.com
Thu Jan 30 07:25:43 UTC 2025


this is my route for sending Push Notification:

route [PN_SEND]
{
    # send a PN using, for example, exec or rest_client
    # Define FCM URL
    $var(fcm_url) = "
https://fcm.googleapis.com/v1/projects/xxx/messages:send
<https://fcm.googleapis.com/v1/projects/asterisk-push-notificaiton/messages:send>
";

    # Set HTTP headers
    rest_append_hf("Authorization: Bearer ya29.c.c0AS...");
    #rest_append_hf("Content-Type: application/json");
    rest_append_hf("Content-Type: \"application/json\"");

    # Create JSON payload
    $var(json_payload) = '{\"message\": {\"token\":
\"xxx\",\"notification\": {\"title\": \"Notification Title\",\"body\":
\"Notification Body\"}}}';

    # Send REST POST request
    if (launch(rest_post($var(fcm_url), "$var(json_payload)",
$avp(response_body), $avp(response_code)))) {
        xlog("L_INFO", "Push notification sent successfully. Response code:
$avp(response_code)\n");
    } else {
        xlog("L_ERR", "Failed to send push notification. Response code:
$avp(response_code)\n");
    }
}

But I get the following error while running Opensips:
ERROR:rest_client:rest_append_hf_method: header field buffer too small
Jan 30 12:29:09 ngdcs opensips[102753]: ERROR:core:get_cmd_fixups: Variable
in param [3] is not a string
Jan 30 12:29:09 ngdcs opensips[102753]: ERROR:core:do_action: Failed to get
fixups for launch command <rest_post>

Can you pls help to resolve the issue?

-- 
Regards,
B.Prathibha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20250130/cea7b2b4/attachment.html>


More information about the Users mailing list