title: How to resolve error: An unexpected 'StartArray' node was found when reading from the JSON reader. A 'StartObject' node was expected.?
body: <p>I am trying to add an entity to Dynamics 2016 On Premise using the Web API.  The Entity references three other entities.  When I try to post the Entity, I receive the following error.</p>
  
  <blockquote>
    <p>An unexpected 'StartArray' node was found when reading from the JSON reader. A 'StartObject' node was expected.</p>
  </blockquote>
  
  <p>This error occurs on the three entities I am referencing: ccseq_clientid, ccseq_employeeid, ccseq_setid.</p>
  
  <p>I have looked at <a href="https://stackoverflow.com/questions/35409243/json-error-when-using-web-api-ms-crm">this</a> question and <a href="https://sharepoint.stackexchange.com/questions/157572/how-to-change-a-view-with-rest-api-web-service-call-in-javascript">this</a> question, but without success.</p>
  
  <p>What does this error mean and how can I resolve it?</p>
  
  <p><strong>Variables</strong></p>
  
  <pre><code>public contentType: string = "application/json;";
  public dataType: string = "json";
  public expenseTransaction: string = this.connection + "ccseq_expensetransactions";
  public expenseTransactionSet: string = this.connection + "ccseq_expensetransactionsets";
  public client: string = this.connection + "ccseq_clients";
  public systemUser: string = this.connection + "systemusers";
  </code></pre>
  
  <p><strong>Ajax Call</strong></p>
  
  <pre><code>Create(expenses: Array&lt;ExpenseTransactionBase&gt;): void {
      for (let i: number = 0; i &lt; expenses.length; i++) {
          $.ajax({
              url: this.expenseTransaction,
              type: "POST",
              contentType: this.contentType,
              accepts: this.contentType,
              dataType: this.dataType,
              data: JSON.stringify(expenses[i].toJSON()),
              success: function (data: any): void {
                  alert("Success");
              },
              error: function (data: any) {
                  alert("error");
              }
          });
      }
  };
  </code></pre>
  
  <p><strong>JSON Creation</strong></p>
  
  <pre><code>toJSON(): any[] {
       let json = [];
       json[0] = {
           "ccseq_clientid@odata.bind": this.client + "(" + this.ccseq_clientid + ")",
           "ccseq_clientnumber": this.ccseq_clientnumber,
           "ccseq_employeefirstname": this.ccseq_employeefirstname,
           "ccseq_employeelastname": this.ccseq_employeelastname,
           "ccseq_employeeid@odata.bind": this.systemUser + "(" + this.ccseq_employeeid + ")",
           "ccseq_expenseerrorcode": this.ccseq_expenseerrorcode,
           "ccseq_generalledgername": this.ccseq_generalledgername,
           "ccseq_generalledgernumber": this.ccseq_generalledgernumber,
           "ccseq_groupcode": this.ccseq_groupcode,
           "ccseq_mastercardposteddate": this.ccseq_mastercardposteddate,
           "ccseq_mastercardtransactiondate": this.ccseq_mastercardtransactiondate,
           "ccseq_mastercardtransactionparentcompany": this.ccseq_mastercardtransactionparentcompany,
           "ccseq_navcompanycode": this.ccseq_navcompanycode,
           "ccseq_navemployeeid": this.ccseq_navemployeeid,
           "ccseq_navgeographycode": this.ccseq_navgeographycode,
           "ccseq_navjobclasscode": this.ccseq_navjobclasscode,
           "ccseq_navservicecode": this.ccseq_navservicecode,
           "ccseq_setid@odata.bind": this.expenseTransactionSet + "(" + this.ccseq_setid + ")",
           "ccseq_transactionamount": this.ccseq_transactionamount,
           "ccseq_transactiondate": this.ccseq_transactiondate,
           "ccseq_transactiondescription": this.ccseq_transactiondescription,
           "ccseq_transactiontype": this.ccseq_transactiontype,
           "ccseq_vendor": this.ccseq_vendor,
           "statecode": this.statecode
       };
  
       return json;
   }
  </code></pre>