<div dir="ltr">If you're trying to modify the contact on your branch I believe you need to do that in a branch route. For example in branch_<span style="font-size:12.8px">route[EVAPIRESPONSE] you could modify the contact header and. Just make sure to set the branch route in route[EVAPIRESPONSE]. </span><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Then instead of using a var you could use an avp. avp's work as a stack so a single avp could hold all of your contacts. In your branch route you could then do something like:</span></div><div><br></div><div><span style="font-size:12.8px">remove_hf('Contact');</span><br style="font-size:12.8px"><span style="font-size:12.8px">append_hf('Contact: $avp(contact)</span><span style="font-size:12.8px">');</span></div><div><span style="font-size:12.8px">pv_unset ("$avp(contact)"); # This will pop the first contact off the avp so the next time you call this avp you'll get the second contact</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">I hope that's helpful and gives you some ideas.<br></span><div class="gmail_extra"><div><div class="gmail_signature"><table style="max-width:580px;border:none;border-collapse:collapse" width="100%"><tbody><tr><td style="padding:0px"><table width="100%"><tbody></tbody></table></td></tr></tbody></table></div></div>
<br><div class="gmail_quote">On Fri, Nov 3, 2017 at 12:00 PM, Diego Nadares <span dir="ltr"><<a href="mailto:dnadares@gmail.com" target="_blank">dnadares@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi john, thanks for your answer. I'm using this in route[EVAPIRESPONSE] because of async request with evapi.<br><br>I tried what you said too with no success.<br><br>                #$var(first) = 0;<br><br>                #while ($var(i) < $var(contacts_len)){<br><br>                #       jansson_get("contacts[$var(i)]<wbr>", "$var(evmsg)", "$var(contact)");<br><br>                #       if ($var(first) == 0){<br><br>                #               $ru = $var(contact);<br><br>                #               $var(first) = 1;<br><br>                #       }       <br><br>                #       append_branch($var(contact), "0.5");<br><br>                #       $var(i) = $var(i) + 1;<br><br>                #}<br><br>                remove_hf('Contact');<br><br>                append_hf('Contact: <<a href="mailto:1111@188.111.111.113" target="_blank">1111@188.111.111.113</a>>');<span class="gmail-"><br><br>                send_reply("302", "Moved Temporarily");<br><br>                exit;<br><br><br></span>The result is ONLY the original uri in the contact. <b>Contact: <<a href="mailto:1111@188.111.111.112" target="_blank">1111@188.111.111.112</a>></b><span class="gmail-HOEnZb"><font color="#888888"><div><b><br></b></div><div>Diego<br></div><div><div><br></div><div><br></div></div></font></span></div><div class="gmail-HOEnZb"><div class="gmail-h5"><div class="gmail_extra"><br><div class="gmail_quote">2017-11-02 22:22 GMT-03:00 John Petrini <span dir="ltr"><<a href="mailto:jpetrini@coredial.com" target="_blank">jpetrini@coredial.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><span style="font-size:12.8px">remove_hf('Contact') and then append_hf($var(contact)) should work. What was the problem you were having? Were you using it in a branch route?</span><br></div><div class="gmail_extra"><br clear="all"><div><div class="gmail-m_-2955143228636049114m_-4948583311514156089gmail_signature"><p> </p><table style="max-width:580px;border:none;border-collapse:collapse" width="100%"><tbody><tr><td style="padding:0px"><table style="border:none;border-collapse:collapse"><tbody><tr><td bgcolor="#089eda" nowrap style="padding:0px;font-family:Helvetica,Arial,sans-serif"><img border="0" height="45" src="https://i.xink.io/Images/Get/N63353/c554.gif" style="border: none; background-color: rgb(8, 158, 218); vertical-align: top; display: block;" width="49"></td><td bgcolor="#089eda" nowrap style="padding:0px 5px 0px 15px;background-color:rgb(8,158,218);color:rgb(255,255,255);font-family:Helvetica,Arial,sans-serif;font-weight:400;vertical-align:middle;line-height:1"><h2 style="margin:0px;font-size:20px;color:rgb(255,255,255);font-weight:normal;letter-spacing:1px">John</h2></td><td nowrap style="padding:0px;font-family:Helvetica,Arial,sans-serif"><img border="0" height="45" src="https://cdn2.hubspot.net/hubfs/210539/email/si-email-signature/coredial-email-signature-blue-cap.gif" style="border: none; vertical-align: top; display: block;" width="22"></td></tr></tbody></table><table width="100%"><tbody><tr><td style="padding:0px"><div style="float:left;vertical-align:top"><table width="100%"><tbody><tr><td style="padding:15px 0px 0px;font-family:Helvetica,Arial,sans-serif;vertical-align:top" width="100%"><table style="border:none;border-collapse:collapse" width="100%"><tbody><tr><td colspan="2" style="padding:0px 0px 10px"><table style="border:none;border-collapse:collapse"><tbody><tr><td style="padding:0px;font-family:Helvetica,Arial,sans-serif;font-size:12px"><p style="margin:0px;text-transform:uppercase;letter-spacing:1px"><span style="font-weight:bold;color:rgb(42,156,217)">John Petrini</span> <span style="color:rgb(170,170,170)">|</span> <span style="color:rgb(119,119,119)">Platforms Engineer</span></p></td></tr></tbody></table></td></tr><tr><td style="padding:0px 0px 5px" width="100%"><div style="float:left;vertical-align:top;width:240px"><table style="border:none;border-collapse:collapse;max-width:240px" width="100%"><tbody><tr><td style="padding:0px 5px 0px 0px" width="13"><img border="0" src="https://cdn2.hubspot.net/hubfs/210539/email/si-email-signature/coredial-email-signature-email-icon.gif" style="vertical-align: middle; border: 0px;" width="13"></td><td style="font-family:Helvetica,Arial,sans-serif"><p style="font-family:Helvetica,Arial,sans-serif;margin:0px;font-size:12px;line-height:1.5"><a href="mailto:jpetrini@coredial.com" style="color:rgb(85,85,85);text-decoration:none" target="_blank">jpetrini@coredial.com</a></p></td></tr></tbody></table></div> <div style="float:left;vertical-align:top;width:185px"><table style="border:none;border-collapse:collapse;max-width:220px" width="100%"><tbody><tr><td style="padding:0px 5px 0px 0px" width="13"><img border="0" src="https://cdn2.hubspot.net/hubfs/210539/email/si-email-signature/coredial-email-signature-phone-icon.gif" style="vertical-align: middle; border: 0px;" width="13"></td><td style="font-family:Helvetica,Arial,sans-serif"><p style="margin:0px;font-size:12px;line-height:1.5"><a href="tel:215-297-4400" style="font-family:Helvetica,Arial,sans-serif;color:rgb(85,85,85);text-decoration:none" target="_blank">215.297.440</a>0</p></td></tr></tbody></table></div> </td></tr><tr><td style="padding:0px" width="100%"><div style="float:left;vertical-align:top;width:240px"><table style="border:none;border-collapse:collapse;max-width:240px" width="100%"><tbody><tr><td style="vertical-align:top;padding:0px 5px 0px 0px" width="13"><img border="0" src="https://cdn2.hubspot.net/hubfs/210539/email/si-email-signature/coredial-email-signature-location-icon.gif" style="vertical-align: middle; border: 0px; color: rgb(85, 85, 85);" width="13"></td><td style="color:rgb(85,85,85);padding:0px;font-family:Helvetica,Arial,sans-serif"><p style="font-family:Helvetica,Arial,sans-serif;margin:0px;font-size:12px;line-height:1.5;color:rgb(85,85,85)">751 Arbor Way, Hillcrest I, Suite 150 <br> Blue Bell, PA 19422</p></td></tr></tbody></table></div> <div style="float:left;vertical-align:top;width:185px"><table style="border:none;border-collapse:collapse;max-width:220px" width="100%"><tbody><tr><td style="padding:0px 5px 0px 0px" width="13"><img border="0" src="https://cdn2.hubspot.net/hubfs/210539/email/si-email-signature/coredial-email-signature-website-icon.gif" style="vertical-align: top; border: 0px;" width="13"></td><td style="padding:0px;font-family:Helvetica,Arial,sans-serif"><p style="font-family:Helvetica,Arial,sans-serif;margin:0px;font-size:12px;line-height:1.5"><a href="https://coredial.com/" style="color:rgb(85,85,85);text-decoration:none" target="_blank">www.coredial.com</a></p></td></tr></tbody></table></div> </td></tr><tr><td colspan="1" style="padding:7px 0px 0px"><table><tbody><tr><td style="padding:0px 20px 0px 0px" width="124"><img border="0" src="https://cdn2.hubspot.net/hubfs/210539/email/si-email-signature/coredial-email-signature-logo.gif" style="vertical-align: middle; border: 0px;" width="124"></td><td style="padding:0px 5px 0px 0px" width="24"><a href="https://twitter.com/coredial" style="text-decoration:none" target="_blank"><img border="0" src="https://cdn2.hubspot.net/hubfs/210539/email/si-email-signature/coredial-email-signature-twitter.gif" style="vertical-align: middle; border: 0px;" width="24"></a></td><td style="padding:0px 5px 0px 0px" width="24"><a href="https://www.linkedin.com/company/coredial-llc" style="text-decoration:none" target="_blank"><img border="0" src="https://cdn2.hubspot.net/hubfs/210539/email/si-email-signature/coredial-email-signature-linkedin.gif" style="vertical-align: middle; border: 0px;" width="24"></a></td><td style="padding:0px 5px 0px 0px" width="24"><a href="https://plus.google.com/+Coredial" style="text-decoration:none" target="_blank"><img border="0" src="https://cdn2.hubspot.net/hubfs/210539/email/si-email-signature/coredial-email-signature-googleplus.gif" style="vertical-align: middle; border: 0px;" width="24"></a></td><td style="padding:0px" width="24"><a href="https://success.coredial.com/blog" style="text-decoration:none" target="_blank"><img border="0" src="https://cdn2.hubspot.net/hubfs/210539/email/si-email-signature/coredial-email-signature-blog.gif" style="vertical-align: middle; border: 0px;" width="24"></a></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></div> <div style="float:left;vertical-align:top;width:120px"><table width="100%"><tbody><tr><td style="padding:20px 0px 0px;vertical-align:top;text-align:center" width="100%"><img border="0" src="https://cdn2.hubspot.net/hubfs/210539/email/si-email-signature/coredial-email-signature-tmc-award.gif" style="max-width: 100%; border: 0px;" width="111"></td></tr></tbody></table></div> </td></tr><tr><td style="padding:0px"><table width="100%"><tbody><tr><td colspan="2" style="padding:7px 0px 0px;font-family:Helvetica,Arial,sans-serif;font-size:10px;color:rgb(145,146,146);max-width:580px"><div style="float:left;vertical-align:top"><p style="margin-top:0px;font-family:Helvetica,Arial,sans-serif;font-size:10px;color:rgb(145,146,146)">The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.</p></div> </td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></div></div>
<br><div class="gmail_quote"><div><div class="gmail-m_-2955143228636049114h5">On Thu, Nov 2, 2017 at 6:40 PM, Diego Nadares <span dir="ltr"><<a href="mailto:dnadares@gmail.com" target="_blank">dnadares@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="gmail-m_-2955143228636049114h5"><div dir="ltr">Hi again,<div><br></div><div>I found a work around . Modifying $ru changes de first contact uri.</div><div><br></div><div><span><div> if($var(routing)=~"redirect")<wbr>{</div><div>                jansson_get("contacts_len", "$var(evmsg)", "$var(contacts_len)");</div><div>                xlog("L_INFO", "Contacts len $var(contacts_len)");</div><div>                $var(i) = 0;</div><div><br></div></span><div>                <b>$var(first) = 0;</b></div><span><div>                while ($var(i) < $var(contacts_len)){</div><div>                        jansson_get("contacts[$var(i)]<wbr>", "$var(evmsg)", "$var(contact)");</div></span><div>                        if ($var(first) == 0){</div><div>                               <b> $ru = $var(contact);</b></div><div>                              <b>  $var(first) = 1;</b></div><div>                        }</div><div>                        #Appending anyway because of the q param</div><span><div>                        append_branch($var(contact), "0.5");</div><div>                        $var(i) = $var(i) + 1;</div><div>                }</div><div>                send_reply("302", "Moved Temporarily");</div><div>                exit;</div><div>        }</div></span></div><div><br></div><div><div><span style="font-size:12.8px">Contact: </span><b><span style="font-size:12.8px"><</span><a href="mailto:sip%3A1111@188.111.111.112" style="font-size:12.8px" target="_blank">1111@188.111.111.112</a><span style="font-size:12.8px"><wbr>></span></b><span style="font-size:12.8px">, <</span><a href="mailto:sip%3A1111@188.111.111.112" style="font-size:12.8px" target="_blank">sip:1111@188.111.111.112</a><span style="font-size:12.8px">>;q=</span><span style="font-size:12.8px">0<wbr>.5, <</span><a href="mailto:sip%3A1111@188.111.111.112" style="font-size:12.8px" target="_blank">sip:1111@188.111.111.112</a><span style="font-size:12.8px">>;q=</span><span style="font-size:12.8px">0<wbr>.5</span><br></div></div><div><br></div><div><br></div><div>I think this is not the better way. Any suggestion will be very appreciated.</div><div><br></div><div>Thanks again.</div><span class="gmail-m_-2955143228636049114m_-4948583311514156089HOEnZb"><font color="#888888"><div><br></div><div>Diego</div><div><br></div></font></span></div><div class="gmail-m_-2955143228636049114m_-4948583311514156089HOEnZb"><div class="gmail-m_-2955143228636049114m_-4948583311514156089h5"><div class="gmail_extra"><br><div class="gmail_quote">2017-11-02 18:11 GMT-03:00 Diego Nadares <span dir="ltr"><<a href="mailto:dnadares@gmail.com" target="_blank">dnadares@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Guys,<div><br></div><div>I'm generating a 302 reply from kamailio. In this 302 I append new branches with new </div><div>contacts. </div><div><br></div><div><div>if($var(routing)=~"redirect"){</div><div>                jansson_get("contacts_len", "$var(evmsg)", "$var(contacts_len)");</div><div>                xlog("L_INFO", "Contacts len $var(contacts_len)");</div><div>                $var(i) = 0;</div><div>                while ($var(i) < $var(contacts_len)){</div><div>                        jansson_get("contacts[$var(i)]<wbr>", "$var(evmsg)", "$var(contact)");</div><div>                        append_branch($var(contact), "0.5");</div><div>                        $var(i) = $var(i) + 1;</div><div>                }</div><div>                send_reply("302", "Moved Temporarily");</div><div>                exit;</div><div>        }</div></div><div><br></div><div>The problem i'm facing is that I can't delete the original contact  <b><<a href="http://sip:1111@188.111.111.111:5060" target="_blank">sip:1111@188.111.111<wbr>.111:5060</a>></b></div><div><br></div><div>The resulting conctact:<br></div><div><br></div><div>Contact: <b><<a href="http://sip:1111@188.111.111.111:5060" target="_blank">sip:1111@188.111.111.111:5060</a><wbr>></b>, <<a href="mailto:sip%3A1111@188.111.111.112" target="_blank">sip:1111@188.111.111.112</a>>;q=0<wbr>.5, <<a href="mailto:sip%3A1111@188.111.111.112" target="_blank">sip:1111@188.111.111.112</a>>;q=0<wbr>.5<br></div><div><br></div><div>I all ready tried with remove_hf('Contact') and adding the new ones after that but it doesn't worke either.</div><div><br></div><div>The problem is that one gw takes the first contact over and over again and never the other two.</div><div><br></div><div>Thanks in advance.</div><span class="gmail-m_-2955143228636049114m_-4948583311514156089m_-1721638625677358756HOEnZb"><font color="#888888"><div><br></div><div>Diego.</div><div><br></div><div><br></div><div><br></div><div><br></div></font></span></div>
</blockquote></div><br></div>
</div></div><br></div></div>______________________________<wbr>_________________<br>
Kamailio (SER) - Users Mailing List<br>
<a href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a><br>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/cgi<wbr>-bin/mailman/listinfo/sr-users</a><br>
<br></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
Kamailio (SER) - Users Mailing List<br>
<a href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a><br>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/cgi<wbr>-bin/mailman/listinfo/sr-users</a><br>
<br></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
Kamailio (SER) - Users Mailing List<br>
<a href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a><br>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/<wbr>cgi-bin/mailman/listinfo/sr-<wbr>users</a><br>
<br></blockquote></div><br></div></div></div>