Get SIP Call-ID From ARI
Based on postings it should be possible to get the SIP Call-ID header value from the ARI. At what point is this value available ? As well, how do I
retrieve that value – something like
GET /channels/{channelId}/pjsip_header?key
3 thoughts on - Get SIP Call-ID From ARI
‘pjsip_header’ is not a valid route. All possible routes are documented on the wiki, if it’s not there then it doesn’t exist.
Instead you would use variable[1] to execute the PJSIP_HEADER dialplan function[2] or a better way would be the CHANNEL dialplan function[3] such as:
GET /channels/{channelid}/variable?variable=CHANNEL(pjsip,call-id)
Though I haven’t tested that.
Newer versions also include the protocol identifier (Call-ID) in the channel ARI structure[4] which would be in events, or explicitly retrieved[5].
[1]
https://wiki.asterisk.org/wiki/display/AST/Asterisk+20+Channels+REST+API#Asterisk20ChannelsRESTAPI-getChannelVar
[2]
https://wiki.asterisk.org/wiki/display/AST/Asterisk+20+Function_PJSIP_HEADER
[3] https://wiki.asterisk.org/wiki/display/AST/Asterisk+20+Function_CHANNEL
[4]
https://wiki.asterisk.org/wiki/display/AST/Asterisk+20+REST+Data+Models#Asterisk20RESTDataModels-Channel
[5]
https://wiki.asterisk.org/wiki/display/AST/Asterisk+20+Channels+REST+API#Asterisk20ChannelsRESTAPI-get
I tried
GET /channels/{channelid}/variable?variable=CHANNEL(pjsip,call-id)
But it responds with
“message”: “Channel not in Stasis application”
Since I want to get the call-id for a channel not in stasis I guess that won’t work. Similarly, I can’t force the channel through my own code in the dialplan, so the PJSIP_HEADER function won’t work. So it looks like I’ll have to upgrade my Asterisk test system to get the Call-ID from the ARI event. It looks like it was added in Ast 16.
Out of curiosity, I see that call-id is returned in the “protocol_id” field of channel data structure. However, since all channels in the same call must have the same Call-ID, how can this data be associated with a channel? Wouldn’t it have to be associated with a bridge? The Call-ID should not be available until two legs are bridged (I think).
Brian
From: asterisk-users [mailto:asterisk-users-bounces@lists.digium.com] Based on postings it should be possible to get the SIP Call-ID header value from the ARI. At what point is this value available ? As well, how do I retrieve that value – something like
GET /channels/{channelId}/pjsip_header?key=Call-Id
But that doesn’t work.
‘pjsip_header’ is not a valid route. All possible routes are documented on the wiki, if it’s not there then it doesn’t exist.
Instead you would use variable[1] to execute the PJSIP_HEADER dialplan function[2] or a better way would be the CHANNEL dialplan function[3] such as:
GET /channels/{channelid}/variable?variable=CHANNEL(pjsip,call-id)
Though I haven’t tested that.
Newer versions also include the protocol identifier (Call-ID) in the channel ARI structure[4] which would be in events, or explicitly retrieved[5].
[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+20+Channels+REST+API#Asterisk20ChannelsRESTAPI-getChannelVar
[2] https://wiki.asterisk.org/wiki/display/AST/Asterisk+20+Function_PJSIP_HEADER
[3] https://wiki.asterisk.org/wiki/display/AST/Asterisk+20+Function_CHANNEL
[4] https://wiki.asterisk.org/wiki/display/AST/Asterisk+20+REST+Data+Models#Asterisk20RESTDataModels-Channel
[5] https://wiki.asterisk.org/wiki/display/AST/Asterisk+20+Channels+REST+API#Asterisk20ChannelsRESTAPI-get
All channels in a call do not have the same Call-ID. Each channel has its own SIP Call-ID (if it is a PJSIP channel) as they are individual call legs and individual SIP dialogs.