title: always getting Invalid grant_type parameter or parameter missing but works on postman
body: <p>I am trying to get my access token with a post request.
  I have tried the request on postman and it works perfectly.
  but when trying from my app I get the error</p>
  
  <blockquote>
    <p>{error: "invalid_request", error_description: "Invalid grant_type parameter or parameter missing"}</p>
  </blockquote>
  
  <p>This is the java code that i have tried:</p>
  
  <pre><code>    RestAssured.baseURI 
      ="http://localhost:8180/auth/realms/acme/protocol/openid- 
      connect/token";
      RequestSpecification request = RestAssured.given();
  
      JSONObject requestParams = new JSONObject();
      requestParams.put("grant_type", "password");
      requestParams.put("username", "amineamine"); // Cast
      requestParams.put("password", "amineamine");
      requestParams.put("client_id", "app-backend-springboot");
      requestParams.put("client_secret",  "9a1707db-431d-437c-bb70- 
      0e5f5d61dcb0");
  
      request.body(requestParams.toJSONString());
      request.header("Content-Type", "application/x-www-form-urlencoded; 
      charset=UTF-8");
  
      Response response = request.post();
      int statusCode = response.getStatusCode();
      System.out.println(response.print());
      System.out.println("The status code recieved: " + statusCode);
      System.out.println("Response body: " + 
      response.body().asString());
  </code></pre>
  
  <p>These are the imports:</p>
  
  <pre><code>import io.restassured.RestAssured;
  import io.restassured.response.Response;
  import io.restassured.specification.RequestSpecification;
  import org.json.simple.JSONObject;
  </code></pre>
  
  <blockquote>
    <p>in postman
    <a href="https://i.stack.imgur.com/GwU7z.png" rel="nofollow noreferrer">enter image description here</a></p>
  </blockquote>