I am trying to send a string type list to mysql database with retrofit. When I try with postman I get success but I am getting error message from android studio.
My API Interface :
@FormUrlEncoded
@POST("yesilegeservices/insertJob.php")
fun insertJob (@Field("Token") token:String,
@Field("StartingDate") StartingDate:String,
@Field("TargetTime") TargetTime:String,
@Field("JobContent") JobContent:String,
@Field("StaffList[]") StaffList:List<String>, // My List
@Field("ReleaseDate") ReleaseDate:String,
@Field("KindId") kindId:String):Single<JobInsertResponse>
My data Class for Response :
data class JobInsertResponse(
@SerializedName("job") @Expose val incomingId:List<singleUuid>,
@SerializedName("jobInsertSuccess") val success:Int
)
data class singleUuid (
@SerializedName("JobId") @Expose val uuid:Int
)
Php response :
{"job":[{"JobId":"15"}],"jobInsertSuccess":1}
Android studio error message:
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was
STRING at line 3
column 1 path $
OkHttp log :
2021-07-02 15:49:31.350 16777-16916/com.thic.yesilege
I/okhttp.OkHttpClient: --> POST
http://10.0.2.2:8888/yesilegeservices/insertJob.php
2021-07-02 15:49:31.350 16777-16916/com.thic.yesilege
I/okhttp.OkHttpClient: Content-Type: application/x-www-form-
urlencoded
2021-07-02 15:49:31.351 16777-16916/com.thic.yesilege
I/okhttp.OkHttpClient: Content-Length: 211
2021-07-02 15:49:31.352 16777-16916/com.thic.yesilege
I/okhttp.OkHttpClient:
Token=yN4XGdFIzIMOrgE3Q4rB1jqoNJUbpfOqHI3IuuiUU&StartingDate=02-
07-
2021&TargetTime=15.49&JobContent=lorem%20impsun%20dolor&
StaffList%5B%5D=10&StaffList%5B%5D=11&StaffList%5B%5D=12
&ReleaseDate=02-07-2021&KindId=1
2021-07-02 15:49:31.352 16777-16916/com.thic.yesilege
I/okhttp.OkHttpClient: --> END POST (211-byte body)
2021-07-02 15:49:31.381 16777-16916/com.thic.yesilege
I/okhttp.OkHttpClient: <-- 200 OK
http://10.0.2.2:8888/yesilegeservices/insertJob.php (28ms)
2021-07-02 15:49:31.381 16777-16916/com.thic.yesilege
I/okhttp.OkHttpClient: Date: Fri, 02 Jul 2021 12:49:39 GMT
2021-07-02 15:49:31.381 16777-16916/com.thic.yesilege
I/okhttp.OkHttpClient: Server: Apache/2.4.46 (Unix)
OpenSSL/1.0.2u PHP/8.0.0 mod_wsgi/3.5 Python/2.7.13
mod_fastcgi/mod_fastcgi-SNAP-0910052141 mod_perl/2.0.11
Perl/v5.30.1
2021-07-02 15:49:31.381 16777-16916/com.thic.yesilege
I/okhttp.OkHttpClient: X-Powered-By: PHP/8.0.0
2021-07-02 15:49:31.381 16777-16916/com.thic.yesilege
I/okhttp.OkHttpClient: Content-Length: 98
2021-07-02 15:49:31.381 16777-16916/com.thic.yesilege
I/okhttp.OkHttpClient: Keep-Alive: timeout=5, max=100
2021-07-02 15:49:31.381 16777-16916/com.thic.yesilege
I/okhttp.OkHttpClient: Connection: Keep-Alive
2021-07-02 15:49:31.381 16777-16916/com.thic.yesilege
I/okhttp.OkHttpClient: Content-Type: text/html; charset=UTF-8
2021-07-02 15:49:31.381 16777-16916/com.thic.yesilege
I/okhttp.OkHttpClient:
2021-07-02 15:49:31.381 16777-16916/com.thic.yesilege
I/okhttp.OkHttpClient:
2021-07-02 15:49:31.381 16777-16916/com.thic.yesilege
I/okhttp.OkHttpClient: Incorrect date value: '02-07-2021' for
column 'ReleaseDate' at row 1
2021-07-02 15:49:31.381 16777-16916/com.thic.yesilege
I/okhttp.OkHttpClient: <-- END HTTP (98-byte body)
I think the problem is in the list I posted because If I delete the list, the result is successful.
What's wrong ?