[OpenSIPS-Users] rest_append_hf

Pasan Meemaduma pasandev at ymail.com
Thu Feb 15 04:53:44 EST 2018


Hi List,
I'm trying to use rest_append_hf function to append an extra header for my rest call. But it doesn't set it unless I call the same function twice.
How do I get around this ? I tried async() statement as well as per docs but it didn't work either.
I'm using opensips 2.3.3
route(xxxx);

route[xxxx] {
    rest_append_hf("Accept: application/vnd.xxx.vapi+json; version=2");
    $var(rc) = rest_post("http://{{ API_USER }}:{{ API_SECRET }}@{{ API_HOST }}/xx/xx/xx", "{ \"xx\": { \"xx\": [ \"$var(auth_user)\" ] }}", "application/json", "$var(body)", "$var(ct)", "$var(rcode)");
    $json(res) := $var(body);
    if($json(res/success) != 1 ) {
        xlog("L_ERR", "API: Failed to Blocked call request - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
    } else {
        xlog("L_WARN", "API: Blocked call request - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
    }
}

Accept header will only send if I call route(xxxx) twice :/.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20180215/73628e78/attachment.html>


More information about the Users mailing list