Set Reason header on 603 SIP Packet

Hi,
I need to configure 603+, so the idea is to send Reason “Network Blocked” with the 603 response code.
I tried testing these two options in the dial plan calling internally from an extension but the Reason message is not showing up.

A)
extensions.conf:
[from-internal]
exten => _.,1,Set(SIP_HEADER(Reason)=“Q.850;cause=21;text=‘Network Blocked’”)
exten => _.,n,Hangup(603)

[Apr 10 17:32:51] VERBOSE[3543817][C-00000021] pbx.c: Executing [1000050@from-internal:1] Set(“SIP/enswitch-local-00000036”, “SIP_HEADER(Reason”) in new stack
[Apr 10 17:32:51] WARNING[3543817][C-00000021] pbx_variables.c: Set requires an ‘=’ to be a valid assignment.
[Apr 10 17:32:51] DEBUG[3543817][C-00000021] pbx.c: Launching ‘Hangup’
[Apr 10 17:32:51] VERBOSE[3543817][C-00000021] pbx.c: Executing [1000050@from-internal:2] Hangup(“SIP/enswitch-local-00000036”, “603”) in new stack

Because of previous message then I also tried with SIPAddHeader:

B)
extensions.conf:
[from-internal]
exten => _.,1,SIPAddHeader(Reason: Q.850;cause=21;text=“Network Blocked”)
exten => _.,n,Hangup(603)

Asterisk full log:
[Apr 10 15:53:12] DEBUG[3512898][C-0000001f] chan_sip.c: SIP Header added “Reason: Q.850” as __SIPADDHEADER01
[Apr 10 15:53:12] DEBUG[3512898][C-0000001f] pbx.c: Launching ‘Hangup’
[Apr 10 15:53:12] VERBOSE[3512898][C-0000001f] pbx.c: Executing [1000050@from-internal:2] Hangup(“SIP/enswitch-local-00000035”, “603”) in new stack

Could it be because Asterisk is using chan_sip and it must be chan_pjsip?
Do you know if there is a way to set this up?

Thank you.

Asterisk doesn’t allow you to set headers on other than INVITE requests.

You should be trying to avoid the use of chan_sip.

chan_pjsip has a different way of adding headers (again only for INVITE).

The error message is telling you that you have a syntax error (it was expecting “=”, but found “)”).

Most of your priority 1 line has been commented out.

Asterisk is an ISDN PABX with VoIP bolted on, so the parameter of Hangup is a Q.850 code, not a SIP status code.

It is not good practice to try to use add header functionality to add headers that the system generates automatically.

If it doesn’t do what you want for Hangup(21), it isn’t going to be possible without source code changes.