I am trying to retrieve an unknown PJSIP header from Asterisk using the ARI. I seem to be able to do this by calling the GET endpoint for channel variables, passing PJSIP_HEADER(read,MyHeaderKey).
I was expecting a 404 if the header was not defined, but I guess this is calling the PJSIP function internally which is throwing?
I am left questioning that perhaps I am going about this the wrong way? I saw this earlier discussion that mentions using the CHANNEL function, but I am not sure this works in my case, where the header is unknown - ARI - Get Call-Id on Dialed Channel
PJSIP_HEADER is the method to retrieve headers, there are some attributes of the call which are made available on the CHANNEL dialplan function but not all headers.
Thanks for the quick reply! Is this is the expected way to retrieve PJSIP headers via ARI? i.e. call a method via the variable endpoint?
Is there a method I should be calling to determine if the header exists first? Or should I just retrieve and catch/ignore the 500 when the header isn’t present?
Is this a bug I should report? or is the 500 internal server error expected?
That is the way to retrieve such information. There is no other way. I’m not sure if it is expected or not, the problem is I can see both sides of the argument. The dialplan function was found, and executed, but returned an error because nothing inside of it was retrieved so do you provide that level of information, or do you say that neither was found.
My concern with the 500 response is that if I assume a 500 means the variable is missing/undefined, then real problems in the back-end will be ignored/misinterpreted.
Thanks for the info, I can progress now based on this.