Skip to content
Advertisement

Retrofit Post Request Error – java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $

I am trying to make a Post Request using Retrofit, MVVM, Coroutines and Hilt.

After sending the post request I get this error

java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $

(I have searched but none was helpful)

AppModule

JavaScript

ApiService

JavaScript

ApiDataSource

JavaScript

NewUser

JavaScript

RegisterRepo

JavaScript

RegisterViewModel

JavaScript

JsonResponse

JavaScript

RegisterFragment

JavaScript

This is the response after testing with POSTMAN. it was working

JavaScript

Update RESOURCE class

JavaScript

UPDATE – FULL LOGCAT

JavaScript

PHP SCODE

JavaScript

}

Advertisement

Answer

I had to decode the JSON sent to the server especially when the content type here is application/json

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement