Accessing SIP Headers from a specific Channel

Hi Everyone ,

I am trying to access some headers like (From , To , Call-ID) but from a specific channel .

For Ex:
If I have Channel A is calling Channel B , if I added Option (U) in the Dial Application it will get me the headers from Channel B , but I am trying to do is to get headers from Channel A like post answer .
Is this something doable ? in the dialplan I mean

Additional note , I am using PJSIP Driver

Thank You

You have to run the code on the right channel. I can’t remember, but IMPORT might work.

Like this IMPORT(channel,variable) , OK I have the channel name , What is the variable , incase I want to get the From Header as example

If it works, it is the function that you would call if running the code on the right channel, and, as with a simple variable, without the ${…}.

How can I run the import on Channel A after the call answered , that’s the problem

They won’t have changed, and your U subroutine will run after B is answered and go do the IMPORT.

I think it would help if you explained why you are trying to do this, as this seems to be a case of confusion between the actual goal and a possible way of achieving it. It may well be that you can’t do what you want.

OK , I am trying to get the SIP headers (From , To , Call-ID) of the first channel after the call had been answered , not before . this is my goal

  1. That is not your goal, unless this is a homework exercise.

  2. Asterisk only accesses the headers on the initial INVITE, which means they never change, as the call progresses.

They can easily changed after the call has been answered like the to-tag will be appended to the To field after 200 OK recieved . And this my goal , and Idk why you are saying this

I believe you will have to read that separately. The A side is normally incoming, and to-tag is sent on the first response, except possibly 100, not just the final one. I’d expect, for an incoming call, Asterisk to allocate a to tag on receiving the INVITE.