Layer7 API Management

  • 1.  POST request body modification

    Posted Dec 12, 2018 11:25 AM

    Hello, 

     

    If the incoming request method to proxy url (created through CA API Gateway) is GET, then I can play around with the context variables using ${request.http.parameters}. However if the request type is POST and I need to edit the request body and add some extra content (e.g. date) before passing on to the back-end service, then how to do it? I tried using ${request.http.body}/${request.body} etc. but while debugging it always showed null.

    Please suggest.



  • 2.  Re: POST request body modification
    Best Answer

    Broadcom Employee
    Posted Dec 12, 2018 12:06 PM

    Hi Pramod,

     

    The request body is available in the variable: ${Request.mainpart}.

     

    I.e: If I posed a username and password

    username=joe&password=test

     

    Request.mainpart will be equal to username=joe&password=test

     

    If you need to grab a specific parameter, ie: username you could use:

     

    ${request.http.parameters.username}

     

    Hope this helps.

     

    Regards,

    Joe



  • 3.  Re: POST request body modification

    Posted Dec 12, 2018 12:24 PM

    Hi Joe, 

     

    I am testing on Postman where I add two parameters to a request body and then start Policy Manager in the Debug mode. However, ${Request.mainpart} is still null 

     

    Is the example of username=joe&password=test for Get method or Post ?



  • 4.  Re: POST request body modification

    Posted Dec 12, 2018 12:38 PM

    Thanks, It worked.



  • 5.  Re: POST request body modification

    Broadcom Employee
    Posted Dec 12, 2018 12:49 PM

    Glad to hear... Just for completeness here.. yes it was from an HTTP POST.