how to set body for application/x-www-form-urlencoded

2,747 views
Skip to first unread message

Manan Kapoor

unread,
May 25, 2016, 8:08:47 AM5/25/16
to wiremock-user
I am trying to create the POST request as below:

{
    "request": {
        "method": "POST",
        "url": "/guidesearchrest/rulesearch",
"headers": {
"Content-Type": {
                "equalTo": "application/x-www-form-urlencoded"
            }
},
"bodyPatterns" : [ 
{"matches" : "a:100"} ,
{"matches" : "b:0"},
{"matches" : "c:Sports_and_Events_ESPN"},
{"matches" : "d:content:F79C33040002407F"}
 ]
},
    "response": {
            "status": 200,
"bodyFileName": "/json/test.json"
    }
}

I am not able to get the result. My body is in x-www-form-urlencoded format. 

When I am using REST client(Chrome POSTMAN) , I am able to get the result. 

Is there any different way to define the body. Please suggest.

Tom Akehurst

unread,
May 25, 2016, 12:50:49 PM5/25/16
to wiremock-user
Using "matches" for the body expressions means you're using a regex across the whole body content. It looks like "contains" might suit better in your case.
Reply all
Reply to author
Forward
0 new messages