Visa Developer Community

Regular Visitor

Can not deserialize instance of com.visa.developer.sample.card_services_api.model.Subscriptions

Sample codes not working for card services.   Issue seems to be with JSON Arrays being passed into the Java Classes for conversion.   All tests end up failing in the sample codes for Card Services API:

 

"com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of com.visa.developer.sample.card_services_api.model.Subscriptions out of START_ARRAY token
at [Source: {"cardholderLowBalanceAmount": {"amount": 0, "currencyCode": "840"}, "pushID": "test", "subscriptions": [{"notificationID": "LowBalance_Email", "isSubscribed": true}, {"notificationID": "ChangeOfCardStatus_Text", "isSubscribed": true}, {"notificationID": "DailyAvailableBalance_PushNotification", "isSubscribed": true}}; line: 1, column: 105] (through reference chain: com.visa.developer.sample.card_services_api.model.NotificationSubscriptionsputPayload["subscriptions"])

at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:270)
at com.fasterxml.jackson.databind.DeserializationContext.reportMappingException(DeserializationContext.java:1234)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1122)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1075)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromArray(BeanDeserializerBase.java:1371)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:174)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:150)
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:504)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:104)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:276)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3814)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2858)
at com.visa.developer.sample.card_services_api.api.CardServicesApiTest.putnotificationSubscriptionsTest(CardServicesApiTest.java:522)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

"

5 REPLIES 5
Regular Visitor

Re: Can not deserialize instance of com.visa.developer.sample.card_services_api.model.Subscriptions

this is for the Java code sample of the Card Services API.

 

 

CardServicesApiTest:

 

@Test
public void putnotificationSubscriptionsTest() throws IOException {

 String jsonPayload = transformPayload("{\"cardholderLowBalanceAmount\": {\"amount\": 0, \"currencyCode\": \"840\"}, \"pushID\": \"test\", \"subscriptions\": [{\"notificationID\": \"LowBalance_Email\", \"isSubscribed\": true}, {\"notificationID\": \"ChangeOfCardStatus_Text\", \"isSubscribed\": true}, {\"notificationID\": \"DailyAvailableBalance_PushNotification\", \"isSubscribed\": true}]}");

ObjectMapper mapper = new ObjectMapper();
NotificationSubscriptionsputPayload body = mapper.readValue(jsonPayload, NotificationSubscriptionsputPayload.class);

//transformPayload()
String cardId = Arrays.asList("cardId_example").get(0);
System.err.println(cardId);

NotificationSubscriptionsputResponse response = api.putnotificationSubscriptions(body, cardId);
}

 

----

//(from: NotificationSubscriptionsputPayload.class)

 

 

public NotificationSubscriptionsputPayload subscriptions(Subscriptions subscriptions) {
this.subscriptions = subscriptions;
return this;
}

 

Visa Dev Moderator

Re: Can not deserialize instance of com.visa.developer.sample.card_services_api.model.Subscriptions

Hi,

 

Thanks for bringing this to our notice. Please let me know if you are able to fix it by updating the model classes. We will take a look and plan for a fix in future release.

 

Thanks,

Jai

Regular Visitor

Re: Can not deserialize instance of com.visa.developer.sample.card_services_api.model.Subscriptions

are you able to reproduce the issue on your end?

 

i'm also getting HTTP 400 Bad Request for all the other tests

Regular Visitor

Re: Can not deserialize instance of com.visa.developer.sample.card_services_api.model.Subscriptions

anyone?

Highlighted
Community Manager

Re: Can not deserialize instance of com.visa.developer.sample.card_services_api.model.Subscriptions

@erek - are you still experiencing this? Please let me know.