title: Unable to fetch data from REST API through Wrapper Class in RXJAVA Android
body: <p>I am working on registering a user through an REST API . I am doing it with RXJAVA and MVVM architecture pattern. The User object is wrapped around a wrapper class called the RegisterResource class.  It shows an Error like this: 
  <strong>java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 2 path $</strong></p>
  
  <pre><code>regUser.setValue(RegisterResource.loading((User)null));
      final LiveData&lt;RegisterResource&lt;User&gt;&gt; source = LiveDataReactiveStreams.
              fromPublisher(registerApi.
                      registerUser(email, name, password)
  
  
                      .onErrorReturn(new Function&lt;Throwable, User&gt;() {
                          @Override
                          public User apply(Throwable throwable) throws Exception {
                              User errorUser = new User();
                              Log.d(TAG, "apply: "+ throwable.getMessage());
                              errorUser.setEmail("-1");
                              Log.d(TAG, "apply: Error " + errorUser.getEmail());
                              return errorUser;
                          }
                      })
  
                      .map(new Function&lt;User, RegisterResource&lt;User&gt;&gt;() {
                  @Override
                  public RegisterResource&lt;User&gt; apply(User user) throws Exception {
                      if (user.getEmail().equals("-1")) {
                          return RegisterResource.error("Could not Register", (User) null);
                      }
                      Log.d(TAG, "apply:  Map Function " + user.getEmail());
                      return RegisterResource.authenticated(user);
                  }
              }).subscribeOn(Schedulers.io()));
  
      regUser.addSource(source, new Observer&lt;RegisterResource&lt;User&gt;&gt;() {
          @Override
          public void onChanged(RegisterResource&lt;User&gt; userRegisterResource) {
              regUser.setValue(userRegisterResource);
              regUser.removeSource(source);
          }
      });
  </code></pre>
  
  <p>The Structure of the REST API is : </p>
  
  <pre><code>{"id":0,"unique_id":2,"name":"Sam 000","email":"sam@gmail.com","encrypted_password":"282492b281b968bc33b361ed8b2d3ad1e2fe861e0ec85d1c7549c626bcddc42428asdfasdfasfsfasfasfsfasfas135be30ffswjioiuias47911e8502ec1b830b21af7a4a6f24d3f733asdasjyowah00dbb4409e890c92cb","salt":"9fc29dljshdojhaspkdpqb25bda4sarfwdgAe8b","created_at":"2019-05-24T08:58:18.000Z","updated_at":"2019-05-24T08:58:18.000Z"}
  </code></pre>
  
  <p>The Activity is as follows </p>
  
  <pre><code>    private void subscribeObservers(){
      registerViewModel.observeUser().observe(this, new Observer&lt;RegisterResource&lt;User&gt;&gt;() {
          @Override
          public void onChanged(RegisterResource&lt;User&gt; userRegisterResource) {
              if(userRegisterResource !=null){
  
                  switch (userRegisterResource.status) {
  
                      case LOADING:{
                          showProgressBar(true);
                          break;}
                      case AUTHENTICATED: {
                          showProgressBar(false);
                          Log.d(TAG, "onChanged:  Registration SUCCESS : " + userRegisterResource.data.getEmail());
                          onRegistrationSuccess();
                          Toast.makeText(RegisterActivity.this, "Success", Toast.LENGTH_SHORT).show();
                          break;
                      }
                      case ERROR: {
                          showProgressBar(false);
                          Log.d(TAG, "onChanged: Error: " + userRegisterResource.message);
                          Toast.makeText(RegisterActivity.this, userRegisterResource.message , Toast.LENGTH_SHORT).
                                  show();
                          break;
                      }
                      case NOT_AUTHENTICATED: {
                          showProgressBar(false);
                          break;
                      }
                  }
              }
          }
      });
  }
  </code></pre>