title: PowerShell does not invoke REST API correctly
body: <p>I have a POST REST API as follows</p>
  
  <pre><code>http://9e459ba0.ngrok.io/SizeAuditor/RecordBaselineData
  </code></pre>
  
  <p>It is invoked with this JSON body as payload, and inserts data correctly to the required database.</p>
  
  <pre class="lang-json prettyprint-override"><code>[
      {
          "projectName" : "fab",
          "commitHash" : "4251CA37541CE059CF354CCD7F1E2AAFD6C2342F",
          "size" :
          {
              "fileName" : "hosts",
              "fileSize" : 100
          }
      }
  ]
  </code></pre>
  
  <p>However, when I use powershell, as follows, the API gets invoked but returns with an error, which leads me to believe that the payload is not sent through correctly. </p>
  
  <pre class="lang-bsh prettyprint-override"><code>$paramsJson = '[ { "projectName" : "fab", "commitHash" : "4251CA37541CE059CF354CCD7F1E2AAFD6C2342F", "size" : { "fileName" : "hosts", "fileSize" : 100 } } ]'
  
  $params = ConvertFrom-Json -InputObject $paramsJson
  
  echo $params
  
  $responseData = Invoke-RestMethod -Uri http://9e459ba0.ngrok.io/SizeAuditor/RecordBaselineData -Method Post -ContentType 'application/json' -Body $params;
  
  echo $responseData
  </code></pre>
  
  <p>I have tried printing out the <code>$params</code> object and also converted it back to JSON using <code>$params | ConvertTo-Json</code> and it seems to be in the correct format, I expect the API to receive. Please suggest what I am doing incorrectly in the PowerShell.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>The error message is as follows, and fails at a certain functions (I have written the REST API as well). However, I would feel it's something related to the payload format, and not the actual data that is being passed, since the JSON format of this passed over Postman succeeds.</p>
  
  <pre>
  Invoke-RestMethod : "An error has occurred.Object reference not set to an
  instance of an object.System.NullReferenceException
     at OneShip.Service.Workers.SizeAuditor.AzureTableStorageProvider.InsertBaselineDataIntoDatabase(BaselineData[] baselineData) in D:\\MyService\\Service\\src\\Workers\\SizeAuditor\\AzureTableStorageProvider.cs:line 52&#xD;\u000a
     at OneShip.Service.SizeAuditorController.&lt;RecordBaselineData&gt;d__7.MoveNext() in D:\\MyService\\Service\\src\\SizeAuditorController.cs:line 76&#xD;\u000a
  --- End of stack trace from previous location where exception was thrown ---&#xD;\u000a
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#xD;\u000a
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#xD;\u000a
     at System.Threading.Tasks.TaskHelpersExtensions.&lt;CastToObject&gt;d__3`1.MoveNext()&#xD;\u000a
  --- End of stack trace from previous location where exception was thrown ---&#xD;\u000a
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#xD;\u000a
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#xD;\u000a
     at System.Web.Http.Controllers.ApiControllerActionInvoker.&lt;InvokeActionAsyncCore&gt;d__0.MoveNext()&#xD;\u000a
  --- End of stack trace from previous location where exception was thrown ---&#xD;\u000a
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#xD;\u000a
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#xD;\u000a
     at System.Web.Http.Controllers.ActionFilterResult.&lt;ExecuteAsync&gt;d__2.MoveNext()&#xD;\u000a
  --- End of stack trace from previous location where exception was thrown ---&#xD;\u000a
     at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#xD;\u000a
     at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#xD;\u000a
     at System.Web.Http.Dispatcher.HttpControllerDispatcher.&lt;SendAsync&gt;d__1.MoveNext()"
  At line:1 char:17
  + ... sponseData = Invoke-RestMethod -Uri http://9e459ba0.ngrok.io/SizeAudi ...
  +                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
      + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
  </pre>