Firstly you should be using at least Asterisk 18. Secondly, there is no such thing as a SIP trunk as far as Asterisk is concerned. The same logic would apply to any SIP peer.
The channel private structure for the outgoing leg no longer exists at the point where you are calling SIP_HEADER, and you are probably also calling it on the wrong channel. However I believe the numeric part of the data is captured, and can be accessed using the HANGUPCAUSE function.
I am able to receive these headers in Success calls. Numeric part was also captured in HANUPCAUSE but only in success calls.
How i can fetch these headers and how i can fetch channel details in failed calls.