Layer7 API Management

 View Only
  • 1.  Set Body for POST Call via HTTP Assertion

    Posted Aug 21, 2017 12:27 PM

    Hi guys I am working on layer7 8.3 Policy manager. I need to make a POST call using policy assertion.

    For making call I am using HTTPS Route assertion. 

     

    How can I add a body in policy? I need to add JSON Body which has to be attached as a body to HTTPS Route assertion.

     

    Sample example:

    URL - POST https://api.data.com

    Body - application/json

    {

    "name":"layer7",

    "something":"nothing"

    }

    wauch01

    Thanks



  • 2.  Re: Set Body for POST Call via HTTP Assertion

    Broadcom Employee
    Posted Aug 21, 2017 03:09 PM

    You may want to try setting a context variable for request with the body.

    If I set a context variable for Message name request then check my request.mainpart it seems to return what I set in the variable. 

    This link discusses using the set context variable assertion to set messages,

    Set Context Variable Assertion - CA API Gateway - 8.3 - CA Technologies Documentation 

     

    Hope that helps some.



  • 3.  Re: Set Body for POST Call via HTTP Assertion

    Broadcom Employee
    Posted Aug 21, 2017 09:42 PM

    Hi siddharth-b ,

    You can create a new message as Charles suggested, and set it as "Request Source" of the route via http(s) assertion.

     

    Regards,

    Mark



  • 4.  Re: Set Body for POST Call via HTTP Assertion

    Posted May 09, 2018 02:41 AM

    Hi Zhijun,

     

    I am trying to do the same but getting an error. 

     

    I created a context variable(say x) in which I selected, 

    Data Type: Message

    Content-Type: application/json

    Expression: I defined my JSON that I need to send as PUT HTTP call to my target

     

    Then in Route via HTTPS, I selected my request source as above context variable(x).

     

    So when I try to send the request, I am getting the following error,

     

    Variable x is not a String and cannot be converted to one. (Actual type: com.I7tech.message.Message)

     

    Can you please suggest and help?

     

    Charles_Lilienkamp Mark_HE siddharth-b



  • 5.  Re: Set Body for POST Call via HTTP Assertion

    Broadcom Employee
    Posted May 09, 2018 06:51 PM

    It seems you have an audit detail assertion and trying to log your custom request message directly, as the error suggested, the your request is a message, not a string, you cannot log it directly, if you want to log the body of the message, you can log the ${x.mainpart}

     

    You may already know it, if you need to send PUT request, on route via http(s) properties, select PUT from the dropdown list for "HTTP Method"



  • 6.  Re: Set Body for POST Call via HTTP Assertion

    Posted May 10, 2018 01:09 AM

    Thanks!! I was directly logging with ${x} as it was a context variable. But now I got it, if request is a message, we need to log using ${x.mainpart}



  • 7.  Re: Set Body for POST Call via HTTP Assertion

    Posted Mar 03, 2019 06:28 PM

    Following up on this.....  Posting a saml response via a browser is usually done as follows:

     

    <form method="post" action="https://sp.example.com/SAML2/SSO/POST" ...>
    <input type="hidden" name="SAMLResponse" value="response" />
    <input type="hidden" name="RelayState" value="token" />
    ...
    <input type="submit" value="Submit" />
    </form>

     

    For some reason , need the gateway itself to do this POST. How would I set a context variable to build this msg that I would use in the route via https assertion? In other words, need to build an HTTP request with the following:

     

    <input type="hidden" name="SAMLResponse" value="response" /> 
    <input type="hidden" name="RelayState" value="token" /> 

     

    type="hidden" probably not neede... since only relevant for browser..

     

     

    Thanks