microsoft / Partner-Center-Java

Partner Center SDK for Java
https://docs.microsoft.com/java/partnercenter/
31 stars 12 forks source link

Deserialize response failed in the scenario of Get invoice unbilled commercial consumption line items #98

Closed Tony-Chou closed 4 years ago

Tony-Chou commented 4 years ago

Steps to reproduce

Running the code list below: SeekBasedResourceCollection seekBasedResourceCollection = scopedPartnerOperations.getInvoices().byId("unbilled").by(BillingProvider.valueOf("ALL"), "USAGELINEITEMS", currencyCode, period, size).get();

Expected behavior

Correct response.

Actual behavior

Throw exception.

Diagnostic logs

Exception msg : Could not deserialize response. Detailed message: Cannot construct instance of java.util.LinkedHashMap (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('')\n at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: com.microsoft.store.partnercenter.models.SeekBasedResourceCollection[\"items\"]->java.util.ArrayList[0]->com.microsoft.store.partnercenter.models.invoices.DailyRatedUsageLineItem[\"tags\"])

Environment

JAVA JDK 1.8.0_211 Partner-Center-Java 1.15.1

Tony-Chou commented 4 years ago

It seems the parameter of [tags] in the [items] of response is an empty string, and the code is trying to deserialize the empty string into Map<String, String> so it throws the exception. I can temporarily fix this issue by adding: jsonConverter.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true); at com.microsoft.store.partnercenter.network.PartnerServiceClient.getJsonConverter() to ignor tit.

ghost commented 4 years ago

@Tony-Chou thank you for reporting this issue! Currently we are working on the next release, and I have just created a pull request with a hotfix for the issue. The hope is that we can push the next release by the end of this week.