title: How to solve error code "405" on API call with testing?
body: <p>I'm getting error code "405" while testing my API calls on run mode in IntelliJ. However when I test the API cal; with the same parameters in Postman it works.</p>
  
  <p>I'm programming a jukebox where an user has to log in in order to use it. The login form works and when i try to log in with Postman it also logs in succesfull. However when i run my code on IntelliJ it gives me error code "405", which means "Method not allowed".</p>
  
  <p>My userController class code which works:</p>
  
  <pre><code>@PostMapping(value = "/login", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
  public String login(@RequestBody MultiValueMap&lt;String, String&gt; body){
      String email = body.getFirst("email");
      String username = body.getFirst("username");
      String password = body.getFirst("password");
  
      return userService.loginUser(email, username, password);
  }
  </code></pre>
  
  <p>My functional testing code(also works because my other GET methods in my API tests works):<br>
      public class FunctionalTest {</p>
  
  <pre><code>@BeforeClass
  public static void setup() {
      String port = System.getProperty("server.port");
      if (port == null) {
          RestAssured.port = Integer.valueOf(8080);
      }
      else{
          RestAssured.port = Integer.valueOf(port);
      }
  
  
      String basePath = System.getProperty("server.base");
      if(basePath==null){
          basePath = "/";
      }
      RestAssured.basePath = basePath;
  
      String baseHost = System.getProperty("server.host");
      if(baseHost==null){
          baseHost = "http://localhost";
      }
      RestAssured.baseURI = baseHost;
  }
  } 
  </code></pre>
  
  <p>And finally my code for testing the POST method for logging in:</p>
  
  <pre><code>//User control
  @Test
  public void checkLogin(){
  
      given()
              .param("email", "123")
              .param("username", "123")
              .param("password", "123")
              .when()
              .get("/login")
              .then()
              .statusCode(200);
  }
  </code></pre>
  
  <p>Hope anyone can help me solve this problem.</p>
  
  <p>Thanks in advance!</p>