Layer7 API Management

  • 1.  Context variable for form data

    Posted Jul 10, 2017 04:55 PM

    What context variable would I utilize to get the form data (key and values) from a POST request?



  • 2.  Re: Context variable for form data
    Best Answer

    Broadcom Employee
    Posted Jul 10, 2017 06:34 PM

    Hello JoePao ,

    ${request.http.parameter.name}
    Used to retrieve the value of an http parameter for the request. Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data.

     

    for example, you have form data

    p1=v1&p2=v2

     

    to get value of p1, you can use ${request.http.parameter.p1}

     

    Regards,

    Mark



  • 3.  Re: Context variable for form data

    Posted Jul 11, 2017 09:22 AM

    I tried the ${request.http.parameter.p1} context variable but received a null value.  I did substitute the "p1" with my own form parameter.  I also have a need to get all the form data either in a string or an array of name value pairs.



  • 4.  Re: Context variable for form data

    Broadcom Employee
    Posted Jul 13, 2017 12:20 AM

    Hello JoePao ,

    The form data is in the body of request, you can get the form data from ${request.mainpart}

    If you cannot get the form data value, it might be due to some special characters in the parameter name, or in the parameter value. If true, you may avoid to use those characters, or url encoded it.

     

    Regards,

    Mark