I am testing a Web Core API and I am getting a 500 Internal Server error. My method on my controller:
[Route("api/property")] public class PropertyController : BaseSirController { [HttpPost("{contractId}/saveproperty")] public IActionResult SaveProperty(int contractId, [FromBody] PropertyContractDto property) { if (property == null) { return BadRequest(); } if (contractId == 0) { return NotFound(); } return Ok();
and in my POwershell command type:
Invoke-RestMethod http://localhost:17972/api/property/7/saveproperty -Method POST -Body (@{UPRN="1244"; StreetName="The Street"; AddressLine2="ALine2"; AddressLine3="ALine3"; AddressLine4="ALine4"; Postcode="N1 7PL"; Latitude="23"; Longitude="77"; BlockUPRN="B1244"; PropertyNo="23"; BlockName="Wenlock Court"; Comments="blah blah blah"; PropertyTypeId="1"; NumberOfBathrooms="1"; NumberOfBedrooms="2"; NumberOfKitchens="1"; PropertyContractId="23"; PropertyType="Maisonette"} | ConvertTo-Json) -ContentType "application/json"
The error message I get is:
Invoke-RestMethod : The remote server returned an error: (500) Internal Server Error. At line:1 char:1 + Invoke-RestMethod http:
I canโt figure out how to fix this.
source share