Calling POST REST API in powershell with headers

In some cases we need to call POST REST API using Powershell. Let’s go through sample code to get to know how it is done using Powershell. In this Article we will go through below topics. Create sample Web API Invoke Web API in Powershell Create Sample Web API Create ASP.NET Core Web Application Select API option Once project created we can see default values controller as below We need our API to accept some Data. So we will create Modal class for that Create Modals Folder Create SampleData class under Modals Folder Add Sample properties to the class. I created Value1 and Value2 as string type. Implement API method in ValuesController as below. [Route(“TestMethod”)] [HttpPost] public ActionResult TestMethod(SampleData data) { // Do what ever with Data var authKey = Request.Headers[“AuthKey”]; return Ok(); } Invoke Web API in Powershell Open Powershell ISE and write following codes to invoke REST API.   Api url $apiUri = “https://localhost:44326/api/values/TestMethod” POST Body Data Object

read more Calling POST REST API in powershell with headers