title: Rest assured testing - API request 401 bad request
body: <p>I have a problem with sending API request via postman or Java lib "io.restassured".
  When I do the same action on UI the request returns correct response, but when I try the same thing via postman or java code I get:</p>
  
  <blockquote>
    <p><h1>401 Bad request</h1> Your browser sent an invalid
    request. </p>
  </blockquote>
  
  <p>The java code </p>
  
  <pre><code>       public static void main(String[] args) {
  
          String requestUrl = "exampleBaseUrl/app/reports/api/rest/v1/graphs?context=shipper&amp;reports_type=freights";
  
   Response response = RestAssured.given().relaxedHTTPSValidation().header("x-csrf-token", "18ea65e740eb0ddddadf0ef435d92564").
              when().
              get(requestUrl);
      }
  </code></pre>
  
  <p>I assume something is wrong with the authentication, because in dev tools i can see a Get request for CSRF_token, and it looks like this:</p>
  
  <p>the endpoint for the token:</p>
  
  <pre><code>/login?get_csrf_token
  </code></pre>
  
  <p>and for this request I get following response:</p>
  
  <pre><code>{"csrf_token":"18ea65e740eb0ddddadf0ef435d92564"}
  </code></pre>
  
  <p>I am not sure how to solve this, I have also tried to get the token via java code by sending a get request to the token's endpoint <code>/login?get_csrf_token</code>
  and this one gets my a HTML response with empty username and password input.</p>