0

At the moment, I am successfully sending a call to a SIP extension using Twilio. I know Twilio support passing extra custom SIP headers to the PBX, and I can do it by doing something like this:

sip:jack@example.com?myHeader=blah

and this works well.

But how can I pass a header which contains an equal sign (=) in its value? For example, let's say 'blah', was 'blah=foobar' instead.

I tried with:

sip:jack@example.com?myHeader=blah=foobar

and of course the call didn't reach my PBX.

Please could anyone help me with this?

Thanks a lot! Fabrizio

2 Answers2

1

You will need to URL encode your value (which you should probably be doing anyway).

An = sign once URL encoded becomes %3D.

So in your example you would need: sip:jack@example.com?myHeader=blah%3Dfoobar

There are various online encoders/decoders and most languages have build in utilities to do this also.

https://www.w3schools.com/tags/ref_urlencode.asp

Andy
  • 698
  • 12
  • 22
  • Hi Andy, thanks for the reply. I am doing it, but then I also need to urlencode the whole string (from sip: to foobar) because that needs to be passed as the value of a POST request to the APIs. And I believe this is what is getting the Twilio APIs knickers in a twist. :) – Fabrizio Vecchi Oct 19 '17 at 07:47
  • I don't think you want to URL encode that part, just the querystring parameters, unless you are also dynamically setting the user@hostname part as well. If so you may need to build up the whole URI separately. I don't know what language you are using but please see https://stackoverflow.com/questions/10786042/java-url-encoding-of-query-string-parameters and https://stackoverflow.com/questions/724043/http-url-address-encoding-in-java – Andy Oct 19 '17 at 13:39
  • Hi Andy, please have a look at https://www.twilio.com/blog/2017/06/introducing-agent-conference-for-contact-centers.html. In the "Outbound Conference Call API" code snippet, they urlencode the To: field too, in its entirety. So I think my approach is correct. With regards to the language, I am using the PHP curl wrapper at the moment (just because it's easier to parse the XML returns from Twilio). I tried with plain curl as well, and had the same problem. – Fabrizio Vecchi Oct 20 '17 at 12:48
  • Hi, That's true they are, but they're also not sending a full SIP URI, at which point I think it will fail due to their end not handling the encoding properly. For example, using their C# SDK I have to url encode the `&` for it to work but I don't have to do that when using the PHP SDK... (although they may have fixed that now, not sure) – Andy Oct 20 '17 at 18:07
  • Have you tried encoding the equals? Are you still not getting the call through? – philnash Oct 21 '17 at 02:57
0

For posterity, the official positon of Twilio is that they don't support passing a list of parameters as a value for a custom SIP header. The support engineer who worked with me on this case made a feature request to the engineering team, so hopefully I will soon be able to solve my problem.