Skip to content

Serializing a parent object with a Chargebee Subscription fails #71

@dcreeronbemo

Description

@dcreeronbemo

Description of the Bug

We have a class that has a property for ChargeBee.Models.Subscription. When we try and serialize this parent class we get an exception with the following details:

Error getting value from 'SubscriptionId' on 'ChargeBee.Models.Subscription+SubscriptionContractTerm'.
The property subscription_id is not present!

If I look in the debug visualizer and drill down to the ChargeBeeSubscription.ContractTerm.SubscriptionId I see a circular red-X for the property, and the value is:

"'(new System.Collections.Generic.ICollectionDebugView<Bemo.Services.ShoppingCart.Models.BemoCartLineItem>(value.LineItems).Items[0]).BemoSub.ChargeBeeSubscription.ContractTerm.SubscriptionId' threw an exception of type 'System.ArgumentException'"

If I clone the latest chargebee-dotnet repository, include the project in my solution, and then comment out the SubscriptionContractTerm.SubscriptionId property in Subscription.cs (lines 6540-6542) then the serialization works as expected. ETA: I can also change that property so the call the GetValue() sets the "required" parameter to false.

Steps to reproduce

  1. Create a parent class with a ChargeBee.Models.Subscription
  2. Populate the parent class, including the CB Subscription property
  3. Try and Serialize the parent class with Newtonsoft
  4. Error/exception as noted in description

Expected Behavior

Serialization should not throw this exception.

Code Snippets (if applicable)

No response

Operating System

Windows 10/11

Language version

.Net 8.0

Library version

v3.20.0

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions