title: .NET Core 2 Web API: [FromBody] nested object was not binded
body: <p>I have that post request in my controller:</p>
  
  <pre><code>[HttpPost("subscriptions")]
  [Authorize(Policy = Policies.Admin)]
  public async Task&lt;IActionResult&gt; PostSubscription([FromBody] PostSubscriptionBindingModel model) { ... }
  </code></pre>
  
  <p>where <code>PostSubscriptionBindingModel</code> is:</p>
  
  <pre><code>public class PostSubscriptionBindingModel
  {
      [Required]
      public DateTime StartsOn { get; set; }
      [Required]
      public DateTime ExpiresOn { get; set; }
      [Required]
      public Gym Gyms { get; set; }
      [Required]
      public int SubscriptionTypeId { get; set; }
      [Required]
      public string UserId { get; set; }
  
      public PaymentBindingModel Payment { get; set; }
  
      public class PaymentBindingModel
      {
          [Required]
          public double Amount { get; internal set; }
          [Required]
          public PaymentType Type { get; internal set; }
          [RequiredArray]
          public InstalmentBindingModel[] Instalments { get; internal set; }
  
          public class InstalmentBindingModel
          {
              [Required]
              public double Amount { get; internal set; }
              public DateTime? ExpiresOn { get; internal set; }
              [Required]
              public bool IsSetPaid { get; internal set; }
          }
      }
  }
  </code></pre>
  
  <p>On <code>Angular</code> (v.6) side I've a service with this method:</p>
  
  <pre><code>postSubscription(model: IPostSubscription): Observable&lt;ISubscription&gt; {
      return this.http.post&lt;ISubscription&gt;(this.originUrl + '/api/subscriptions', model)
          .catch((reason: any) =&gt; this.handleError(reason));
  }
  </code></pre>
  
  <p>When I try to post my object to the web api controller, while inside Angular service <code>postSubscription</code> method the model is fully initialized, on web api side only the first level of the object has values. The property <code>Payment</code> (of nested type <code>PaymentBindingModel</code>) is not null but its properties are not initialized, like they are not binded.</p>
  
  <p>How can I solve this problem?</p>
  
  <p><strong>EDIT (added an image)</strong></p>
  
  <p><a href="https://i.stack.imgur.com/3GRXv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3GRXv.png" alt="enter image description here"></a></p>
  
  <p><strong>EDIT 2 (added client code post model)</strong></p>
  
  <pre><code>export interface IPostSubscription {
      startsOn: Date;
      expiresOn: Date;
      gyms: Gym;
      subscriptionTypeId: number;
      userId: string;
      payment?: ISubscriptionPayment;
  }
  
  export interface ISubscriptionPayment {
      amount: number;
      type: PaymentType;
      instalments: ISubscriptionPaymentInstalment[];
  }
  
  export interface ISubscriptionPaymentInstalment {
      amount: number;
      expiresOn?: Date;
      isSetPaid: boolean;
  }
  </code></pre>
  
  <p>Thank you very much!</p>