title: Retrofit response code 405 with message "method not allowed here"
body: <p>I am using retrofit and I have a post request </p>
  
  <pre><code>interface NetworkApi {
  
  @Headers("Content-Type: application/json")
  @POST("/")
  fun startLoginRequest(@Body loginModel : LoginModel) : Call&lt;BaseResponseModel&gt;
  
  class Factory {
      var retrofit = Retrofit.Builder()
              .baseUrl(BASE_URL)
              .addConverterFactory(GsonConverterFactory.create())
              .build()
  
      companion object{
          fun getApi (): NetworkApi {
              val serverApi = NetworkApi.Factory()
              val api = serverApi.retrofit.create(NetworkApi::class.java)
              return api
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>when I use this method and on response method were calling response body is always null. </p>
  
  <pre><code>fun startLoginRequest(){
      val api = NetworkApi.Factory.getApi()
      val request = api.startLoginRequest(loginRequestModel)
  
      request.enqueue(object : Callback&lt;BaseResponseModel&gt;{
          override fun onFailure(call: Call&lt;BaseResponseModel&gt;?, t: Throwable?) {
  
          }
  
          override fun onResponse(call: Call&lt;BaseResponseModel&gt;?, response: Response&lt;BaseResponseModel&gt;?) {
              //here response.body is null
          }
      })
  }
  </code></pre>
  
  <p><strong>Strange thing is that, if I will send the same object using Postman everything works fine</strong></p>
  
  <p>this is httpClient interceptor log</p>
  
  <pre><code>--&gt; POST http://myExampleHost.net/ http/1.1
  Content-Type: application/json
  
  Content-Length: 95
  Authorization: auth-value
  --&gt; END POST (95-byte body)
  &lt;-- 405 Method Not Allowed http://myExampleHost.net/ (198ms)
  Allow: GET, HEAD, OPTIONS, TRACE, COPY, PROPFIND, LOCK, UNLOCK
  Content-Type: text/html
  Server: Microsoft-IIS/7.5
  X-Powered-By: ASP.NET
  X-Powered-By-Plesk: PleskWin
  Date: Thu, 17 Nov 2016 08:04:57 GMT
  Content-Length: 1107
  &lt;HTML&gt;
  &lt;HEAD&gt;
  &lt;TITLE&gt;405 Method Not Allowed&lt;/TITLE&gt;
  &lt;BASE href="/error_docs/"&gt;&lt;!--[if lte IE 6]&gt;&lt;/BASE&gt;&lt;![endif]--&gt;
  &lt;/HEAD&gt;
  &lt;BODY&gt;
  &lt;H1&gt;Method Not Allowed&lt;/H1&gt;
  The HTTP verb used to access this page is not allowed.&lt;P&gt;
  &lt;HR&gt;
  &lt;ADDRESS&gt;
  Web Server at example address
  &lt;/ADDRESS&gt;
  &lt;/BODY&gt;
  &lt;/HTML&gt;
  </code></pre>
  
  <p>For now I'm using OkHttp RequestBuilder and everything works fine, I don't realize what I'm missing in the above example</p>
  
  <pre><code>val client = OkHttpClient()
      val JSON = MediaType.parse("application/json; charset=utf-8")
      val body = RequestBody.create(JSON,json)
      val request1 = Request.Builder()
              .url("http:example.com")
              .addHeader("content-type", "application/json")
              .method("POST", body)
              .build()
  
      client.newCall(request1).enqueue(object : okhttp3.Callback{
          override fun onFailure(call: okhttp3.Call?, e: IOException?) {
  
          }
  
          override fun onResponse(call: okhttp3.Call?, response: okhttp3.Response?) {
              response?.body()?.string()?.print("RETROFIT response")
          }
      })
  </code></pre>