title: pass collection of objects through http post in angular js
body: <p>I have pass a collection of objects through http post in angular js.</p>
  
  <p>The code is as follows:</p>
  
  <pre><code>  $scope.selectedContent = function () {       
          var contents = $filter('filter')($scope.data.ContentId, { Selected: true });  // I could able to get all the selected objects here, No problem with it        
          var jsonData = angular.toJson(contents); //It is not able to convert to Json if there are more than 5 records
          var promise = $http.post('/webapi/cmsApi/CmsPublishApprovedContent?jsonData=' + jsonData, {});
          promise.success(function () {            
              window.location.reload();
          });
  
  
  
          [ReferrerFilterAttribute]
          [HttpPost]
          [System.Web.Http.ActionName("CmsPublishApprovedContent")]
          public void CmsPublishApprovedContent(string jsonData)
          {
              var contents = JsonConvert.DeserializeObject&lt;List&lt;ContentNodeInWorkFlow&gt;&gt;(jsonData);
  
              foreach (var content in contents)
              {
                  _contentService.PublishContent(content.ContentId,  userId);
              }       
          }
      }
  </code></pre>
  
  <p>The above code works fine if there are 5 records or less. If there are more records, I could able to get all the selected record
  objects in the variable 'contents'. But the problem is occuring when converting to Json for all those objects. I
  have about 500 records to pass through. How can do I it?</p>
  
  <p>There is no specific reason to convert to JSON data. I just need to extract the ids of all the selected items. I have modified the above code as below:</p>
  
  <pre><code>$scope.selectedContent = function () {        
          var contents = $filter('filter')($scope.data, { Selected: true });
          var abc = [];
          angular.forEach(contents, function(content)
          {
              abc.push(content.ContentId); // got all the ids in the array now
          });
  
          var promise = $http.post('/webapi/cmsApi/CmsPublishApprovedContent' ,{contents : abc});
          promise.success(function () {
              window.location.reload();
          });
      }
  </code></pre>
  
  <p>I have just took an array and pushed all the content ids into it. I could able to see all the ids in the array now. I tried to pass the array as above.
  How to retrieve those array in the code behind. </p>
  
  <pre><code>[ReferrerFilterAttribute]
          [HttpPost]
          [System.Web.Http.ActionName("CmsPublishApprovedContent")]
          public void CmsPublishApprovedContent(int[] abc)
          {}
  </code></pre>
  
  <p>I do not see any values obtained under int[] abc. What will be the datatype for the parameter in the method call above.</p>