title: Authorization in POST method using rest assured
body: <p>I'm trying to send a POST method to my API and it returns 401 error instead of 200 OK.</p>
  
  <p>Here is the thing:</p>
  
  <p>Using Postman: POST request works fine.</p>
  
  <p>Under Authorization section, I have selected <code>Basic Auth</code> and have provided Username/pwd.</p>
  
  <p>Under Headers section, I have given <code>X-application</code> and <code>Content-Type</code>.
  My body in Postman is :</p>
  
  <pre><code>{
    "description": "TestAPIPostmannolast",
    "issue_type": {
      "id": "271341877549072389",
      "name": "Design"
    },
    "area": {
      "id": "271341877549072406"
    },
    "issue_id": "9d5ac7da-9626-11e8-9eb6-529269fb1459"
  }
  </code></pre>
  
  <p>Using RestAssured: It fails with a 401 error.</p>
  
  <pre><code>package basic;
  
  import io.restassured.response.Response;
  import org.testng.annotations.BeforeClass;
  import org.testng.annotations.Test;
  import io.restassured.RestAssured;
  import static io.restassured.RestAssured.given;
  
  public class GetRequest {
  
  
      @BeforeClass
      public void setup() {
  
          RestAssured.baseURI = "https://123.com";
  
          RestAssured.basePath = "/field-management/api";
  
          RestAssured.authentication =    RestAssured.basic("username", "password");
  
      }
  
      @Test
      public void responseBody(){
  
          Response response = given()
                  .header("X-application", "63fc4887-aed9-497f-bad5-d7ef2b90cdaf")
                  .contentType("application/json")
                  .body("{\n" +
                          "  \"description\": \"Intellij  \",\n" +
                          "  \"issue_type\": {\n" +
                          "    \"id\": \"271341877549072389\",\n" +
                          "    \"name\": \"Design\"\n" +
                          "  },\n" +
                          "  \"area\": {\n" +
                          "    \"id\": \"271341877549072406\"\n" +
                          "  },\n" +
                          "  \"issue_id\": \"2dd8ae7a-966e-11e8-9eb6-529269fb1459\n" +
                          "\n\"\n" +
                          "}")
  
                  .when()
                  .post("/projects/1879048400/areas/271341877549072406/issue/");
  
          System.out.println(response.body().asString());
      }
  </code></pre>
  
  <p>Response:</p>
  
  <pre><code>{"message":"Authentication Failed","errorKey":null}
  </code></pre>
  
  <p>Not sure why is it not working when I try it through RestAssured.</p>