Forum Discussion

RiteshY's avatar
Occasional Contributor
9 years ago

Replace request content using RequestFilter.filterRequest does not work

I want to send urlencoded request, to achive that I am using following code in RequestFilter.filterRequest


def requestHeaders = request.getRequestHeaders()
def contentType = requestHeaders.get("Content-Type")[0].trim().toLowerCase()
def reqContent = context.requestContent

if (contentType=="application/x-www-form-urlencoded" && reqContent){
	reqContent ='\t', '    ').replaceAll('\r\n|\n', ''), 
	context.requestContent = "=$reqContent".toString()


But It doesn't send URLEncoded request. According to article, it should work. Am I missing something?



I don't want to use SubmitListener.beforeSubmit event with request.setRequestContent as It changes request content in the test and next time it becomes unreadable for anyone.

Any Suggestion folks?




9 Replies

  • nmrao's avatar
    Champion Level 3
    Have you tried with below statment?
    'context.requestContent = reqContent'
    • RiteshY's avatar
      Occasional Contributor

      If I try to get request content in SubmitListener.beforeSubmit using context.requestContent. It returns blank.

      I tried setting context.requestContent in SubmitListener.beforeSubmit but it does't work either.


      context.requestContent = reqContent also doesn't work in RequestFilter.filterRequest



      • nmrao's avatar
        Champion Level 3
        Can you log and see what is there in reqContent variable? Have it after the url encode statement.