title: Retrofit parse result in Kotlin
body: <p>I have a webservice that takes username and password in a post request and returns a token (JWT) and a code if http statuscode is 200. If statuscode is 403 then the code contains the details and token is null. On iOS it is working but now I'm trying to implement it in Kotlin and Retrofit.</p>
  
  <p>What I have created so far:</p>
  
  <p>2 DTOs:</p>
  
  <pre><code>class LoginDto(var username: String, var password: String) 
  class LoginResultDto(var accessToken: String, var code: Int) 
  </code></pre>
  
  <p>(JWT handling will be next step) </p>
  
  <p>A client service:</p>
  
  <pre><code>interface ClientService {
  
      @POST("authenticate")
      fun login(@Body body: LoginDto): Single&lt;LoginResultDto&gt;
  
  
      companion object {
          fun create(): ClientService {
  
              val retrofit = Retrofit.Builder()
                      .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                      .addConverterFactory(GsonConverterFactory.create())
                      .baseUrl("https://test-backend.mydomain.com/api/")
                      .build()
  
              return retrofit.create(ClientService::class.java)
          }
      }
  }
  </code></pre>
  
  <p>and the code that calls the service:</p>
  
  <pre><code>private fun login(email: String, password:String){
  
      clientService.login(LoginDto(email,password))
              .subscribeOn(Schedulers.computation())
              .observeOn(AndroidSchedulers.mainThread())
              .subscribe(
              {
                  onSuccess: LoginResultDto? -&gt;
                  onSuccess?.let {
                      Toast.makeText(this, "token: " +it.accessToken + " code: "+it.code+ "success", Toast.LENGTH_SHORT).show()
                  }
              },
              {
                  onError: Throwable -&gt;
                  println(onError)
                  Toast.makeText(this, onError.localizedMessage, Toast.LENGTH_LONG).show()
              }
      )
  }
  </code></pre>
  
  <p>The request itself is working. It returns a 200 with correct login data and 403 with incorrect. But the LoginResultDto is empty.</p>
  
  <p>How can I populate the result in LoginResultDto?</p>