我正在尝试发送一个字符串类型列表到mysql数据库与改型。当我尝试与 Postman 我得到成功,但我得到的错误信息从android工作室。
我的API接口:
@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>
我的响应数据类:
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回应:
{"job":[{"JobId":"15"}],"jobInsertSuccess":1}
Android Studio错误消息:
java.lang.IllegalStateException: Expected BEGIN_OBJECT but was
STRING at line 3
column 1 path $
正常Http日志:
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)
我认为问题出在我发布的列表中,因为如果我删除列表,结果是成功的。
你怎么了?
2条答案
按热度按时间tzcvj98z1#
我认为问题出在你的数据类中。你的作业数组列表包含对象,对象中有一个jobId字符串,但你把它解析为整数。
试试这个解决方案,它可能会有帮助。
siotufzp2#
日期有问题。Mysql数据库接受的日期格式为“yyyy-MM-dd”,但我的日期格式为“dd-MM-yyyy”。