Post method parameter is taken as null when API is invoked from powershell. Below is the JSON
"TestCase":{ "tc_name":"TestCase1" }, "3":{ "scn_desc":"Create Client34345", "test_status":"PASS", "error_link":"" } , "4":{ "scn_desc":"Create Client43634", "test_status":"PASS", "error_link":"" }, "5":{ "scn_desc":"Create Client346346", "test_status":"PASS", "error_link":"" }
}
$json contains the above json array. Powershell: Invoke-WebRequest -Uri http://localhost:65452/api/e10/e10PostTCData -Method Post -Body $json -ContentType 'application/json'
API:
[Route("e10PostTCData/")]
[HttpPost]
public HttpResponseMessage PostResults([FromBody]JsonArray jsonArray )
{
}
public class JsonArray
{
public string json { get; set; }
}
Other way:
[Route("e10PostTCData/")]
[HttpPost]
public HttpResponseMessage PostResults([FromBody]String jsonArray )
{
}
Both the methods shows null as the parameter. Please advise.
Aucun commentaire:
Enregistrer un commentaire