Tropo is part of CiscoLearn More

getHeader

This fetches a particular SIP header for a call. As an example, currentCall.getHeader('x-test-header') will return the data for 'x-test-header'. If multiple headers have the same name, getHeader will return the values of each of them, separated by new lines.

You can add custom headers when invoking a call or transfer method by using the 'headers' attribute; make sure to include x- for your customer headers, e.g. test-header becomes x-test-header. The header will also be downcased, so if you need to access something like x-Test-Header, you would need to write is as x-test-header.

Below are some potential headers you could retrieve using getHeader - the first portion lists the header name while the second portion, after the colon, is sample data that would be returned.

x-sbc-from:"\"username\"<sip:00001234567@192.168.0.101>;tag=2a648c6e",
x-sbc-allow:"BYE",
x-sbc-user-agent:"sipgw-1.0",
x-sbc-contact:"<sip:00001234567@192.168.0.101:16000>",
Content-Length:"247",
To:"<sip:9991234567@10.6.60.100:5060>",
Contact:"<sip:username@10.6.60.100:5060>",
x-sbc-request-uri:"sip:990009369991234567@66.190.50.10:5060",
x-sbc-call-id:"OWE0OGFkMTE1ZGY4NTI1MmUzMjc1M2Y3Y2ExMzc2YhG.",
x-sid:"39f4688b8896f024f3a3aebd0cfb40b2",
x-sbc-cseq:"1 INVITE",
x-sbc-max-forwards:"70",
CSeq:"2 INVITE",
Via:"SIP/2.0/UDP 66.190.50.10:5060;received=10.6.60.100",
x-sbc-record-route:"<sip:190.40.250.230:5061;r2=on;lr;ftag=2a648c6e>",
Call-ID:"0-13c4-4b7d8ff7-1c3c1b82-7935-1d10b081",
Content-Type:"application/sdp",
x-sbc-to:"<sip:990009369991427645@60.190.50.10:5060>",
From:"<sip:username@10.6.60.100:5060>;tag=0-13c4-4b7d8ff7-1c3c1b82-5c7b"

Examples

  if (currentCall.getHeader("x-test-header"))
    {
    log("Your header value is " +currentCall.getHeader("x-test-header"));
    }
else
    {
    log("Your header value was not found");
    }  
if ($currentCall.getHeader("x-test-header"))
    log "Your header value is " + $currentCall.getHeader("x-test-header")
else
    log "Your header value was not found"
end
<?php
if ($currentCall->getHeader("x-test-header")) {
    log("Your header value is " . $currentCall->getHeader("x-test-header"));
    }
else {
    log("Your header value was not found");
    }
?>
if (currentCall.getHeader("x-test-header")) :
    log("Your header value is " + currentCall.getHeader("x-test-header"))
else :
    log("Your header value was not found")
end
if (currentCall.getHeader("x-test-header"))
    {
    log("Your header value is " +currentCall.getHeader("x-test-header"));
    }
else
    {
    log("Your header value was not found");
    }