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_route[EVAPIRESPONSE] you could modify the contact header and. Just make sure to set the branch route in route[EVAPIRESPONSE]. 

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:

remove_hf('Contact');
append_hf('Contact: $avp(contact)');
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

I hope that's helpful and gives you some ideas.

On Fri, Nov 3, 2017 at 12:00 PM, Diego Nadares <dnadares@gmail.com> wrote:
Hi john, thanks for your answer. I'm using this in route[EVAPIRESPONSE] because of async request with evapi.

I tried what you said too with no success.

                #$var(first) = 0;

                #while ($var(i) < $var(contacts_len)){

                #       jansson_get("contacts[$var(i)]", "$var(evmsg)", "$var(contact)");

                #       if ($var(first) == 0){

                #               $ru = $var(contact);

                #               $var(first) = 1;

                #       }      

                #       append_branch($var(contact), "0.5");

                #       $var(i) = $var(i) + 1;

                #}

                remove_hf('Contact');

                append_hf('Contact: <1111@188.111.111.113>');

                send_reply("302", "Moved Temporarily");

                exit;


The result is ONLY the original uri in the contact. Contact: <1111@188.111.111.112>

Diego



2017-11-02 22:22 GMT-03:00 John Petrini <jpetrini@coredial.com>:
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?

 

John

John Petrini | Platforms Engineer

751 Arbor Way, Hillcrest I, Suite 150
Blue Bell, PA 19422

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.


On Thu, Nov 2, 2017 at 6:40 PM, Diego Nadares <dnadares@gmail.com> wrote:
Hi again,

I found a work around . Modifying $ru changes de first contact uri.

 if($var(routing)=~"redirect"){
                jansson_get("contacts_len", "$var(evmsg)", "$var(contacts_len)");
                xlog("L_INFO", "Contacts len $var(contacts_len)");
                $var(i) = 0;

                $var(first) = 0;
                while ($var(i) < $var(contacts_len)){
                        jansson_get("contacts[$var(i)]", "$var(evmsg)", "$var(contact)");
                        if ($var(first) == 0){
                                $ru = $var(contact);
                                $var(first) = 1;
                        }
                        #Appending anyway because of the q param
                        append_branch($var(contact), "0.5");
                        $var(i) = $var(i) + 1;
                }
                send_reply("302", "Moved Temporarily");
                exit;
        }



I think this is not the better way. Any suggestion will be very appreciated.

Thanks again.

Diego


2017-11-02 18:11 GMT-03:00 Diego Nadares <dnadares@gmail.com>:
Hi Guys,

I'm generating a 302 reply from kamailio. In this 302 I append new branches with new 
contacts. 

if($var(routing)=~"redirect"){
                jansson_get("contacts_len", "$var(evmsg)", "$var(contacts_len)");
                xlog("L_INFO", "Contacts len $var(contacts_len)");
                $var(i) = 0;
                while ($var(i) < $var(contacts_len)){
                        jansson_get("contacts[$var(i)]", "$var(evmsg)", "$var(contact)");
                        append_branch($var(contact), "0.5");
                        $var(i) = $var(i) + 1;
                }
                send_reply("302", "Moved Temporarily");
                exit;
        }

The problem i'm facing is that I can't delete the original contact  <sip:1111@188.111.111.111:5060>

The resulting conctact:


I all ready tried with remove_hf('Contact') and adding the new ones after that but it doesn't worke either.

The problem is that one gw takes the first contact over and over again and never the other two.

Thanks in advance.

Diego.






_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users



_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users



_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users