uber / rides-java-sdk

Uber Rides Java SDK (beta)
https://developer.uber.com/docs
MIT License
104 stars 57 forks source link

java sdk payment-method throwing exception #8

Closed rajuans closed 8 years ago

rajuans commented 8 years ago

Hi, I am using v2 sdk to connect to uber. Below is my code snippet to get the payment-methods. I am getting exception at the first line of the below snippet.

Response<PaymentMethodsResponse> paymentMethodResponseRe = uberRidesService.getPaymentMethods(); PaymentMethodsResponse paymentMethodResponse = paymentMethodResponseRe.getBody(); List<PaymentMethod> paymentMethods = paymentMethodResponse.getPaymentMethods();

Below exception while fetching payment-methods for user.

Error 2016-03-02 23:14:30,094 [http-bio-80-exec-1] ERROR errors.GrailsExceptionResolver - IllegalStateException occurred when processing request: [GET] /paymentMethods Expected a string but was BEGIN_OBJECT at line 1 column 103 path $.payment_methods[0].description. Stacktrace follows: Message: Expected a string but was BEGIN_OBJECT at line 1 column 103 path $.payment_methods[0].description Line | Method ->> 837 | nextString in com.google.gson.stream.JsonReader


| 358 | read in com.google.gson.internal.bind.TypeAdapters$13 | 346 | read . . . . . in '' | 103 | read in com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1 | 196 | read . . . . . in com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter | 40 | read in com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper | 81 | read . . . . . in com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter | 60 | read in '' | 103 | read . . . . . in com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1 | 196 | read in com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter | 810 | fromJson . . . in com.google.gson.Gson | 775 | fromJson in '' | 63 | fromBody . . . in retrofit.converter.GsonConverter | 367 | invokeRequest in retrofit.RestAdapter$RestHandler | 220 | access$100 . . in '' | 278 | obtainResponse in retrofit.RestAdapter$RestHandler$2 | 42 | run . . . . . in retrofit.CallbackRunnable | 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor | 615 | run . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker | 94 | run in retrofit.Platform$Base$2$1 ^ 745 | run . . . . . in java.lang.Thread

itstexter commented 8 years ago

Hey @rajuans,

I'm having trouble reproducing your issue. It looks like there is some issue in the object mapping. Could you turn logging on to LogLevel.FULL and post the json body response?

UberRidesSyncService uberRidesService = (UberRidesSyncService) new UberRidesServices.Builder() .setLogLevel(UberRidesServices.LogLevel.FULL) .setSession(session) .build();

I'm getting a response like

{"last_used":"6d57bf0d-fake-fake-fake-d462138b3b27","payment_methods":[{"type":"faketype","description":"email@gmail.com","payment_method_id":"d68ff22e-fake-fake-fake-b81e93d3b9f7"}]

rajuans commented 8 years ago

Hi itstexter,

I realized that I had one class PaymentMethod due to which mapping was failing. Sorry to bother you. Its working fine.

itstexter commented 8 years ago

Oh okay! You're sure it's not with the SDK's mapping? Glad it sounds like it's working!

rajuans commented 8 years ago

Yeah I just checked it. I will test it throughly and let you know if I am struck anywhere.

On Sat, Mar 5, 2016 at 12:21 AM, itstexter notifications@github.com wrote:

Oh okay! You're sure it's not with the SDK's mapping? Glad it sounds like it's working!

— Reply to this email directly or view it on GitHub https://github.com/uber/rides-java-sdk/issues/8#issuecomment-192406614.

Thanks & Regards, Raju 9899980696