Layer7 API Management

  • 1.  Is it possible to access body or form data in a http delete request?

    Posted Jun 12, 2015 06:35 AM

    The Validate HTML Form Data assertion is restricted to GET and POST requests and attempting to retrieve values from ${request.http.parameter.<key>} resutls in a null but I can see that the data is in request.mainpart so I was wondering if there was anyway to access this?

    Ideally I want to use a HTTP DELETE request but i don need to pass in a some meta data with the request and don't really want a massive query string.



  • 2.  Re: Is it possible to access body or form data in a http delete request?

    Posted Jun 12, 2015 10:38 AM

    Hi Andy

    First of all, the Gateway can manipulate a body sent in the request via the DELETE method as normal: ${request.mainpart},

    Secondly, it will not see parameters (${request.http.parameter.test} sent in a 'POST'-like way: as x-www-form-urlencoded, but it will capture them if you put the parameters in the query string (http://..../.../...?test=hello)

     

    I hope it is helpful



  • 3.  Re: Is it possible to access body or form data in a http delete request?

    Posted Jun 15, 2015 04:12 AM

    Thank you for the response garma26. Ideally I don't want to be dealing with querystrings, do you know if there is an easy way to get the key/value pairs out of the ${request.mainpart} string other than using regex? Using the service debugger it appears the form data is coming through as a string value in the form of "key1=value1&key2=value2...". I would like to manipulate this into some kind of object where I can access the value as ${myDataFrom.key1} but can't work out if this is possible.



  • 4.  Re: Is it possible to access body or form data in a http delete request?

    Posted Jun 15, 2015 04:48 AM

    Just to expand on this from my own research, I can pass request.mainpart into a Split Variable assertion on '&' to get an array of key/value pairs. Following this I can use a Run Assertion for Each Item on the split variable result and then pass the currentitem into another Split Variable assertion on '=' to get the key and value parts. What I can't seem to do is save this result into something that I can later access easily. In a programmatic sense I need some kind of dictionary variable which I can use as dictionary[key] = value or dictionary.key =value but I am not sure if the gateway provides anything like this.