title: Wiremock Test for POST returns 404
body: <p>I am new to Wiremock and I am trying to unit test if my login method retrieves the cookie.</p>
  
  <p>Following is my login method:</p>
  
  <pre><code>public String Login() {
      // login url
      String loginURL = baseURL+"/Login?username=admin&amp;password=test&amp;_spring_security_remember_me=true&amp;submit=Login Name";
      HttpHeaders headers = new HttpHeaders();
      headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
      // create the request with headers
      HttpEntity&lt;String&gt; request = new HttpEntity&lt;String&gt;(headers);
      RestTemplate restTemplate = new RestTemplate();
      HttpEntity&lt;String&gt; response = restTemplate.exchange(loginURL, HttpMethod.POST, request, String.class);
      HttpHeaders headerResponse = response.getHeaders();
      // get the cookie
      cookie = headerResponse.getFirst(HttpHeaders.SET_COOKIE);
      return cookie;
  }
  </code></pre>
  
  <p>I have written the below unit test to check if the cookie is returned when the login url is called.</p>
  
  <pre><code>@Test
  public void TestLoginShouldReturnCookie1() {
  stubFor(post(urlEqualTo(myURL+"/Login?username=admin&amp;password=test&amp;_spring_security_remember_me=true&amp;submit=Login%20Name"))
          .willReturn(aResponse().withStatus(200))
          .withCookie("COOKIE", containing(REMEMBER_ME)));
  
  String cookie = loginService.Login();
  
  assertEquals(REMEMBER_ME, cookie);
  
  }
  </code></pre>
  
  <p>When I run the test I am getting 404 error and error with following:</p>
  
  <pre><code>14:27:10.488 [qtp878991463-70] ERROR WireMock - Request was not matched:
  
  {
   "url" : "/Login?username=admin&amp;password=test&amp;_spring_security_remember_me=true&amp;submit=Login%20Name",
   "absoluteUrl" : "http://localhost:8089/Login?username=admin&amp;password=test&amp;_spring_security_remember_me=true&amp;submit=Login%20Name",
   "method" : "POST",
   "clientIp" : "127.0.0.1",
   "headers" : {
      "User-Agent" : "Java/1.8.0_101",
      "Connection" : "keep-alive",
      "Host" : "localhost:8089",
      "Accept" : "text/plain, application/json, application/*+json, */*",
      "Content-Length" : "0",
      "Content-Type" : "application/x-www-form-urlencoded"
    },
   "cookies" : { },
   "browserProxyRequest" : false,
   "loggedDate" : 1516544830458,
   "bodyAsBase64" : "",
   "body" : "",
   "loggedDateString" : "2018-01-21T14:27:10Z"
  }
  Closest match:
    {
      "url" : "http://localhost:8089/Login?username=admin&amp;password=test&amp;_spring_security_remember_me=true&amp;submit=Login%20Name",
     "method" : "POST",
     "cookies" : {
     "COOKIE" : {
     "contains" : 
     "FNROTlvZz09Onp0RmwwRnFqbHd2RXNFOFZiTWNaa"
     }
   }
  }
  </code></pre>
  
  <p>How can I rectify this issue?</p>