Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我没有收到来自RESTAPI使用改型Android的响应_Android_Rest_Retrofit - Fatal编程技术网

我没有收到来自RESTAPI使用改型Android的响应

我没有收到来自RESTAPI使用改型Android的响应,android,rest,retrofit,Android,Rest,Retrofit,下面是我从RESTAPI得到的响应 { "statusCode": "200", "statusData": "Updated Successfully", "responseData": { "bookingId": null, "customerName": null, "customerMobileNumber": null, "patientMobileNumber": null, "driverMobileNumber": "9090909090", "deviceToken": "f

下面是我从RESTAPI得到的响应

{
"statusCode": "200",
"statusData": "Updated Successfully",
"responseData": {
"bookingId": null,
"customerName": null,
"customerMobileNumber": null,
"patientMobileNumber": null,
"driverMobileNumber": "9090909090",
"deviceToken": "f4kc2epndRA:APA91bEXrl4OmlfRUU2M_mfj3khz53_-OgrOk_lpdYWg8hz4hN4yWEogL3eMobH9nPERyO13UN88zQQDUZn262VBv3gICv9BcNECppuJ_G0SlE-1qn57X5w9kMN_q9MXb6ilXQnlIl0A",
"bookedBy": null,
"emergencyType": null,
"emergencyLatitude": 17.443277115352867,
"emergencyLongitude": 78.45206458121537,
"emergencyGeoHashCode": null,
"hospital": null,
"customerId": 0,
"bookingForSelf": 0,
"bookingStatus": "ACCEPTED",
"customerApp": null,
"groupTypeId": 0,
"groupId": 0,
"gcmToken": null,
"hospitalLatitude": 17.8979999,
"hospitalLongitude": 78.7879989,
"hospitalGeoHashCode": null,
"vehicleNumber": null,
"driverName": "santhosh",
"ambulance_start_latitude": 17.786889,
"ambulance_start_longitude": 78.786999,
"vehicle_id": 1,
"booking_id": 201708240006,
"accepted_datetime": 1503556227596,
"vehicleAttributes": null,
"driverImage": "XXXXXX/pic1.png",
"duration": null,
"distance": null
}
}
下面是我尝试过的代码,bookingacceptedresponda是POJO类

    final Call<BookingAcceptedResponseData> upDBooking = apiService.updateBookingStat(updateBookingMap);

    upDBooking.enqueue(new Callback<BookingAcceptedResponseData>() {
        @Override
        public void onResponse(Call<BookingAcceptedResponseData> call, Response<BookingAcceptedResponseData> response) {

            System.out.println("####### Basic updateBookingStat response.body() : "+response.body());
            System.out.println("####### Basic toString updateBookingStat response.body() : "+response.body().toString());

            try {
                if (response.body() != null) {
                    System.out.println("####### updateBookingStat response.body() : "+response.body().toString());
                    Intent it = new Intent(MainActivity.this, DashBoardActivity.class);
                    it.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                    it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    //it.putExtra("bookingDetails", bookingDetails);

                                        finish();

                }
            }catch (Exception e){
                e.printStackTrace();
            }
        }

        @Override
        public void onFailure(Call<BookingAcceptedResponseData> call, Throwable t) {

        }
    });
final Call upDBooking=apiService.updatebokingstat(updatebokingmap);
upDBooking.enqueue(新回调(){
@凌驾
公共void onResponse(调用、响应){
System.out.println(“+response.body()”);
System.out.println(“+response.body().toString()”);
试一试{
if(response.body()!=null){
System.out.println(“+response.body()”);
Intent it=新Intent(MainActivity.this、DashBoardActivity.class);
it.setFlags(Intent.FLAG\u ACTIVITY\u CLEAR\u TASK);
it.setFlags(Intent.FLAG\u ACTIVITY\u NEW\u TASK);
//it.putExtra(“bookingDetails”,bookingDetails);
完成();
}
}捕获(例外e){
e、 printStackTrace();
}
}
@凌驾
失败时公共无效(调用调用,可丢弃的t){
}
});

我得到的回应是
packageName@XXXX
从REST API调用中,我没有得到实际数据。请帮助我。

尝试获得如下响应
response.body().string()
您的响应JSON对象包含JSON对象名称
responseData
要获取
responseData
,您需要进行以下更改。试试这个也许对你有帮助

将响应BookingAcceptedResponse A更改为低于BookingAcceptedResponse类

public class BookingAcceptedResponse{
    private int statusCode;
    private String statusData;
    private BookingAcceptedResponseData responseData; 
    //TODO 
    //generate getter and setter
}
内部追溯调用响应方法更改

response.body().getResponseData();

这将返回正确的数据

我已尝试过,但得到的响应相同”packageName@XXXX“把你的打印输出写在这里…@naveen你能发布
BookingAcceptedResponsta
classHi Akhilesh Patil吗?我会试试的。谢谢你的回复。@naveen我对我的答案做了修改,请让我们看看。