title: Angular JS MVC Web API Model/ Parameter not binding .NET Core
body: <p>I am using Angular JS with TypeScript and  ASP.NET Core MVC/API.</p>
  
  <p>I have an <code>apiService</code> which deals with all <code>POST</code> and <code>GET</code> requests to the server, which looks like this:</p>
  
  <pre><code>module TBApp {
  
      export class apiService {
  
          static $inject = ['$http', 'notificationService'];
  
          constructor(private $http, private notificationService: notificationService) {
  
          }
  
          get(url, config, success, failure) {
  
              return this.$http.get(url, config)
  
                  .then(result =&gt; { this.handleResponse(result, success); }, result =&gt; { this.handleError(result, failure) });
          }
  
          post(url, data, success, failure) {
  
              return this.$http.post(url,data)
                  .then(result =&gt; { this.handleResponse(result, success); }, result =&gt; { this.handleError(result, failure) });
          }
  
          handleResponse(result, success) {
  
              alert('success');
              success(result);
  
          }
  
          handleError(result, failure) {
  
              if (result.status === '401') {
  
                  this.notificationService.displayError('Authentication required.');
                  //this.$rootScope.previousState = this.$location.path();
                  //this.$location.path('/login');
  
              }
              else if (failure !== null) {
                  failure(result);
              }
          }
      }
  }
  </code></pre>
  
  <p>Now when I send this request:</p>
  
  <pre><code>    onCompanyChanged(selectedCompany, model, companyName) {
  
          this.apiService.post('/api/Dashboard/GetAssetListByCompany', { companyId: selectedCompany.id },
  
              response =&gt; {
  
                  this.assetListViewModel = response.data.data;
  
  
              }, response =&gt; {
              this.notificationService.displayError(response.data.message);
          });
      }
  </code></pre>
  
  <p>It is not binding the <code>companyId</code> in the controller</p>
  
  <p>Here is the controller:</p>
  
  <pre><code>   [Route("api/[controller]")]
      public class DashboardController : BaseController
      {
          [HttpPost]
          [Route("GetAssetListByCompany")]
          public IActionResult GetAssetListByCompany([FromBody]int companyId)
          {
              return CreateJsonResult(() =&gt;
              {
                  if (companyId == 0) { return new xPTJsonResult(null, xPTStatusCodesEnum.Success, "Company Id is 0"); }
  
                 //var treeModel = _dashboardProvider.GetTreeModelByCompany(companyId, userModel);
  
                  return new xPTJsonResult(null, xPTStatusCodesEnum.Success, "Loaded assets successfully");
  
              });
          }
  
  }
  </code></pre>
  
  <p>even though when I check the Request in the Browser, in shows that the companyId is in the Payload.</p>
  
  <p><a href="https://i.stack.imgur.com/xPbGN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xPbGN.png" alt="enter image description here"></a></p>
  
  <blockquote>
    <p>NOTE: The same function works when I post a ViewModel</p>
  </blockquote>
  
  <p><strong>EDIT</strong></p>
  
  <p>In the above scenario I am only passing one Parameter to the controller, but in some cases I want to be able to pass 2 or 3 parameters without using a ViewModel.</p>
  
  <p>e.g. </p>
  
  <pre><code>public IActionResult GetAssetListByCompany([FromBody]int companyId, [FromBody]int assetId)
  {....
  </code></pre>
  
  <p>OR </p>
  
  <pre><code>public IActionResult GetAssetListByCompany([FromBody]int companyId, [FromBody]int assetId, [FromBody]bool canEdit = false)
      {.....
  </code></pre>
  
  <p>and then on the client side I can do this:</p>
  
  <pre><code>this.apiService.post('/api/Dashboard/GetAssetListByCompany', { companyId: selectedCompany.id, assetId: 123 }.....
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>this.apiService.post('/api/Dashboard/GetAssetListByCompany', { companyId: selectedCompany.id, canEdit: true, assetId: 22 }....
  </code></pre>