AMI Call with PJSIP

Hai All,

I have Asterisk 16 Server installed on Centos 7.9 with SIP trunk.

Presently am using the Asterisk AMI and chan_sip to make the call using the below AMI action.

telnet 5038

Action: Login
UserName: testuser
Secret: testpassword

Action: Originate
CallerID: 123456
Channel: PJSIP/0123456789@Telecom-sip-trunk
Context: Testcal
Exten: s
Priority: 1
Variable: __SIPADDHEADER51=P-Preferred-Identity: sip:123456@

It’s working being able to make the call using the below action with P-Preferred-Identity SIP Header. But now being migrated from Chan_sip to chan_pjsip and for pjsip am unable to use the > Variable: __SIPADDHEADER51=P-Preferred-Identity: sip:123456@
and the pjsip channel did not allow to set header before the channel is getting created.

How can we set SIPHeader for AMI calls which use PJSIP ?

You use the PJSIP_HEADER dialplan function[1].

[1] Asterisk 18 Function_PJSIP_HEADER - Asterisk Project - Asterisk Project Wiki

@jcolp - Am able to make the call from dialplan setting

exten => 1,1,Dial(PJSIP/${EXTEN},b(handler^addheader^1))

But I am not using dialplan here. I wanted to initiate the call using AMI directly not through dialplan.

Is there way we can set header directly from AMI like SIP Header above instead of Dialplan for pjsip.

Dialplan functions also work in the “Variable” argument.

@jcolp - Thanks . Its worked.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.