title: Android (Java/Kotlin) - Http error 400 - Bad Request and the request have only header without body
body: <p>everyone!</p>
  
  <p>I've been building and app that consumes an API from the company where I work. When I perform a request (GET) with URL connection (through HttpURlConnection) with header (encoding, authorization and etc.) AND a body (as a JSON, using Content-Type = "application/json") the response code is 200 and the connection works pretty good, but and I use the same header in another request BUT WITHOUT a content, I get a Bad Request.</p>
  
  <p>I already tried setting the doOutout = false, but It doesn't work.</p>
  
  <p>I think that everything is OK with the URL and the header because I performed the request by Postman and I got the response.</p>
  
  <p>Here is the way I'm creating the connection and connecting:</p>
  
  <pre><code>val uri = Uri.parse("Base URL").buildUpon().appendPath(path).build() val url = URL(uri.toString()) val connection = url.openConnection() as HttpURLConnection connection.apply {
              addRequestProperty("Charset", Charsets.UTF_8.displayName())
              addRequestProperty("Authorization", "Basic $token")
              addRequestProperty("X-Serial", 5036.toString())
              requestMethod = "GET"
              connectTimeout = 0
              readTimeout = 0
              doOutput = false
              if (responseCode != HTTP_OK) throws Exception("Erro") 
          }
  </code></pre>