title: Getting java.util.NoSuchElementException when trying to do POST to server. The answer from server is 204/success, but exception is still raised
body: <p>I doing POST to my server. The result is 204 / Success code, the body for the result is empty. java.util.NoSuchElementException is raised right after the result from server. My guess is that is because the respond contains no body (Void), but I am very unsure </p>
  
  <p>My interface</p>
  
  <pre><code>    @POST("register/")
      fun register(@Body phone: PhoneBody): Single&lt;Void&gt;
  </code></pre>
  
  <p>PhoneBody 
  <code>data class PhoneBody(val phone: String)</code></p>
  
  <p>My query </p>
  
  <pre><code>  disposable += registrationRepository.register(phone)
              .addSchedulers()
              .doOnSubscribe { viewState.showLoading() }
              .doAfterTerminate { viewState.hideLoading() }
              .subscribe({it -&gt;
                  Log.d("PAPDEB", "$it Personal Acc Presenter")
  
              }, this::handleError)
  </code></pre>
  
  <p>it never goes to in-subscribe lambda, it goes right into this::handle which is</p>
  
  <pre><code>        if (t is ApiException) {
              viewState.showError(t.message)
          } else if (t is IOException) {
              viewState.showError("No internet connection")
          }
  
          if (BuildConfig.DEBUG) {
              t.printStackTrace()
          }
      }
  </code></pre>
  
  <pre><code>D/OkHttp: --&gt; POST https://.../register/
  D/OkHttp: Content-Type: application/json
  D/OkHttp: Content-Length: 24
  D/OkHttp: {"phone":"+79090000000"}
  D/OkHttp: --&gt; END POST (24-byte body)
  D/OkHttp: &lt;-- 204 https://.../register/ (386ms)
  D/OkHttp: server: nginx/1.13.12
  D/OkHttp: date: Tue, 25 Jun 2019 20:52:49 GMT
  D/OkHttp: vary: Accept, Accept-Language, Cookie, Origin
  D/OkHttp: allow: POST, OPTIONS
  D/OkHttp: x-frame-options: SAMEORIGIN
  D/OkHttp: content-language: ru
  D/OkHttp: strict-transport-security: max-age=31536000
  D/OkHttp: &lt;-- END HTTP
  
  W/System.err: java.util.NoSuchElementException
  W/System.err:     at io.reactivex.internal.operators.observable.ObservableSingleSingle$SingleElementObserver.onComplete(ObservableSingleSingle.java:111)
  W/System.err:     at retrofit2.adapter.rxjava2.BodyObservable$BodyObserver.onComplete(BodyObservable.java:66)
  W/System.err:     at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:48)
  W/System.err:     at io.reactivex.Observable.subscribe(Observable.java:12246)
  W/System.err:     at retrofit2.adapter.rxjava2.BodyObservable.subscribeActual(BodyObservable.java:34)
  W/System.err:     at io.reactivex.Observable.subscribe(Observable.java:12246)
  W/System.err:     at io.reactivex.internal.operators.observable.ObservableSingleSingle.subscribeActual(ObservableSingleSingle.java:35)
  W/System.err:     at io.reactivex.Single.subscribe(Single.java:3575)
  W/System.err:     at io.reactivex.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run(SingleSubscribeOn.java:89)
  W/System.err:     at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:578)
  W/System.err:     at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
  W/System.err:     at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
  W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  W/System.err:     at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
  W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
  W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
  W/System.err:     at java.lang.Thread.run(Thread.java:764)
  </code></pre>
  
  <p>I would be very thankful to hear any ideas of what is wrong and how to get to lambda</p>