<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <font face="monospace">The error has nothing to do with PN, but with
      the way you use the rest_post() function. The error log is 100%
      clear - the third param you pass to the function is not a string!<br>
      <br>
      Regards,<br>
    </font>
    <pre class="moz-signature" cols="72">Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
  <a class="moz-txt-link-freetext" href="https://www.opensips-solutions.com">https://www.opensips-solutions.com</a>
  <a class="moz-txt-link-freetext" href="https://www.siphub.com">https://www.siphub.com</a></pre>
    <div class="moz-cite-prefix">On 30.01.2025 09:25, Prathibha B wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAJh_-cCkGwfgARDyaJ5Ec9fGfjtJ6qhsaqq2KNjpdKN63zcWYw@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div>this is my route for sending Push Notification:
          <div><br>
          </div>
          <div>route [PN_SEND]<br>
            {<br>
                # send a PN using, for example, exec or rest_client<br>
                # Define FCM URL<br>
                $var(fcm_url) = "<a
href="https://fcm.googleapis.com/v1/projects/asterisk-push-notificaiton/messages:send"
              target="_blank" moz-do-not-send="true">https://fcm.googleapis.com/v1/projects/xxx/messages:send</a>";<br>
            <br>
                # Set HTTP headers<br>
                rest_append_hf("Authorization: Bearer ya29.c.c0AS...");<br>
                #rest_append_hf("Content-Type: application/json");<br>
                rest_append_hf("Content-Type: \"application/json\"");<br>
            <br>
                # Create JSON payload<br>
                $var(json_payload) = '{\"message\": {\"token\":
            \"xxx\",\"notification\": {\"title\": \"Notification
            Title\",\"body\": \"Notification Body\"}}}';<br>
            <br>
                # Send REST POST request<br>
                if (launch(rest_post($var(fcm_url),
            "$var(json_payload)", $avp(response_body),
            $avp(response_code)))) {<br>
                    xlog("L_INFO", "Push notification sent successfully.
            Response code: $avp(response_code)\n");<br>
                } else {<br>
                    xlog("L_ERR", "Failed to send push notification.
            Response code: $avp(response_code)\n");<br>
                }<br>
            }<br>
          </div>
          <div><br>
          </div>
          <div>But I get the following error while running Opensips:</div>
          <div>ERROR:rest_client:rest_append_hf_method: header field
            buffer too small<br>
            Jan 30 12:29:09 ngdcs opensips[102753]:
            ERROR:core:get_cmd_fixups: Variable in param [3] is not a
            string<br>
            Jan 30 12:29:09 ngdcs opensips[102753]:
            ERROR:core:do_action: Failed to get fixups for launch
            command <rest_post></div>
          <div><br>
          </div>
          <div>Can you pls help to resolve the issue?</div>
        </div>
        <div><br>
        </div>
        <span class="gmail_signature_prefix">-- </span><br>
        <div dir="ltr" class="gmail_signature"
          data-smartmail="gmail_signature">
          <div dir="ltr">
            <div>Regards,</div>
            <div>B.Prathibha<br>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>