Call api with Retrofit

Asked by At

I want to consume athe api located at http://base-url/delivery-orders?driverId.equals=1116

This is my function:

@GET("delivery-orders")
fun getAllDeliveryOrder(
    @Header("Authorization") token: String,
    @Query("driverId") idDriver: Int
): Observable<OrderItems>

but I got error code 500.

3 Answers

2
Jian Astrero On

Error codes from 500-599 are server errors. Meaning, your code is working but the server doesn't. Better recheck the code from the server to fix this error.

2
Rangga Saputra On

This problem usually from server.. try to check Method or maybe there has invinity looping.

My friend also get the same problem, he say you must check database. Maybe your web can't call some data in database. just try delete all or make empty database, and then run again ur Android

0
Ali bana On

I found the problem about that request. the problem is the URL have driverId.equal and my network interface is

@GET("delivery-orders") fun getAllDeliveryOrder(@Header("Authorization") token: String, @Query("driverId") idDriver: Int): Observable<OrderItems>

so retrofit think driverId on URL is driverId in @Query, so I just change "driverId" in @Query with IdDriver. that solve the problem.