I need to get the extension number from the "From header", I have tried everything but nothing worked.
Even tried to do:
byte[] raw = req.getRawContent();
And manually find the From and the number, But that returned null
What am I doing wrong? How to get that number
Get the FromHeader
and then extract the information you need from it. For instance, if the extension is the user part of the URI:
FromHeader fromHeader = (FromHeader) req.getHeader("From");
Address fromAddress = fromHeader.getAddress();
URI fromURI = fromAddress.getURI();
if (fromURI.isSipURI()) {
SipURI fromSipURI = (SipURI) fromURI;
extension = fromSipURI.getUser();
}