API Connect

 View Only
  • 1.  How to extract a variable from one gateway script policy to another

    Posted 12 days ago
    Edited by Raja Kumar 12 days ago

    Hello 

    I'm using 2 gatewayscript policies in my assembly flow. Now, when I try to extract the variable defined in gatewayscript policy 1. Its says that variable is undefined. can you please let me know how we can do this ?

    Gatewayscript policy 1

    let a = test;

    Gatewayscript policy 2

    //trying to print the variable value console.log('value of b is:', context.get('a'));

    in apic logs, it prints as value of b is: a is undefined

    P.S.
    I've tried context.set('') variable in gatewayscript policy 1 but still no luck.  



    ------------------------------
    Raja K
    ------------------------------



  • 2.  RE: How to extract a variable from one gateway script policy to another

    Posted 11 days ago
    // In first Gw script do this
    var context = session.createContext("ctx-01");
    
    // Don't use URL based syntax. It will work but is not good here
    context.setVar("first-name", "Ajitabh");
    
    
    
    // In second Gw script do this
    var context = session.name("ctx-01");
    
    // Reading context variables
    console.error("First log: %s",context.getVar("first-name"));


    ------------------------------
    Ajitabh Sharma
    ------------------------------



  • 3.  RE: How to extract a variable from one gateway script policy to another

    Posted 9 days ago

    Thank you Ajitabh.

    I have a token and along with token cdata is also formed. Now i want to remove the CDATA section and want only token content. how i can do this in gatewayscript ?

    <data contentType="application/x-www-form-urlencoded">

    <![CDATA[token]]> </data>



    ------------------------------
    Raja Kumar
    ------------------------------