title: How to pass json obj value to API in angular (for post method)
body: <p>Here i am trying to post some data to API.but it does not work.because i have got 400 bad request.i think my service or typescript is not fine.when trying to postman I got the output.so i confirm my Web APi is working fine. actually I am new in angular.so please helpme for this i am a beginner.i search so many times here but didn't get the answer. here my api is accepting value by json obj
  like (Note i am using angular4 web Api)</p>
  
  <pre><code>{ 
   "Header": {
  
          "UserID": 6,
         "created": "February 4, 2016 10:13:00",
          ....etc........
       },
  
    "detail": [
  {
  
    "ShopID": 1,
   "ItemID": 126,
  .....etc.........
    },
    {     
   "ShopID": 1,
   "ItemID": 127,
  .....etc.........
   }
   ]
   }
  </code></pre>
  
  <p>but my datas are passing to API is like (so i think this is the problem)</p>
  
  <pre><code>    [{
    "userid": "64",
    "created": "February 4, 2016 10:13:00",
    "CompanyID": "1",
    "modified": "February 4, 2016 10:13:00",
    "modifieduserid": "65",
    "confirm": "true",
    "ShopId": 1,
    "TransactionId": 1,
     "shopid": 12,
    "Itemid": 12928,
    "PackingTypeID": 3,
    "Itemcode": "124018",
    "Itemdescription": "COTTON GLOVES 350G",
    "PackingtypeName": "12 PCS",
    "Stockcount": 12
  </code></pre>
  
  <p>}
  ]</p>
  
  <p><strong>And this is my ts file</strong></p>
  
  <pre><code>     stockitems: IStockCountHeaders[] = [];   
   items: IStockCountHeaders;
    stockdetail: IStockdetails[] = [];
  
    addItems(value: any) {
  this.items = new IStockCountHeaders(this.userid, this.created, t this.confirm,this.shopid, 
   value.ItemID, value.PackingTypeID, value.ItemCode, value.ItemDescription, 
   value.PackingtypeName, 
      value.Stock,
     );
  this.stockitems.push(this.items);
    }
  onclick(){
   this._enqService.CatchStockDetailHeader(this.stockitems)
      .subscribe(value =&gt; {
          if (typeof value !== 'undefined' &amp;&amp; value != null) {
              value.forEach(items =&gt; {
                  this.stockitems.push(this.items)
              });
          }
      },
          error =&gt; {
              console.error(error);
              this.statusMessage = "Problem with the service.Please try again after sometime";
          });
   }
  </code></pre>
  
  <p><strong>this is my angular service file</strong></p>
  
  <pre><code>          CatchStockDetailHeader(stock: any)
      : Observable&lt;IStockCountHeaders[]&gt; {
      let IStockCounts = stock;  
      console.log(IStockCounts)
      let headers = new Headers({ 'Content-Type': 'application/json' });
      let options = new RequestOptions({ headers: headers });
      headers.append('userid', IStockCounts.userid);
      headers.append('created', IStockCounts.created);
      headers.append('.CompanyID', IStockCounts.CompanyID);
      headers.append('modified', IStockCounts.modified);
      headers.append('modifieduserid', IStockCounts.modifieduserid);
      headers.append('confirm', IStockCounts.confirm);    
      return this._http.post('http://localhost:3071/api/Stockcountheader/' + 'Stock', IStockCounts, options)
          .map((response: Response) =&gt; &lt;IStockCountHeaders[]&gt;response.json())
          .catch(this.handleError);
  }
  </code></pre>