I am using web api 2 and .net core 2.0
I'm trying to post to an endpoint but the propertyId in the in the query is always null, but the value in the body is populated. If I change propertyId to an int, it gets populated.
After LOTS of reading I found this, which has "confirmed" - for me - that what I've done should be working. It's not so I don't know what I'm missing. There are many threads on this issue but none have helped me. Could someone please advise what i'm missing?
I have tried a number of variations, including:
- passing the query as ?propertyId=teststring
- Removing [FromQuery]
- Removing Route
- Changing headers
Combos of above
public class RoomsController : ControllerBase { ...other stuff... [HttpPost, Route("{propertyId}")] public async Task<IActionResult> Post([FromQuery]string propertyId, [FromBody]List<CreateRoomRequestDto> value) { List<Guid> result = await _mediator.Send(new NewRoomRequest() { PropertyId = propertyId, NewRoom = value }); return Ok(result); } }
http://localhost:49942/api/Rooms/testString
the postman script
POST /api/Rooms/testString HTTP/1.1
Host: localhost:49942
Cache-Control: no-cache
Content-Type: application/json
Postman-Token: f15b569d-84a2-4bde-bdf0-b1cdf3fff975
[
{
"Tag":"30dd879c-ee2f-11db-8314-0800200c9a66",
"Name":"testName",
"Description": "tesDescription",
"Length": 1.5,
"Width": 1.8,
"Dimension": 5,
"DimensionText": "some DimensionText test",
"PhotoUrls": ["klklkl", "oioioioii"]
},
{
"Tag":"30dd879c-ee2f-11db-8314-0800200c9a66",
"Name":"testName2",
"Description": "tesDescription2",
"Length": 1.2,
"Width": 1.9,
"Dimension": 5,
"DimensionText": "some DimensionText test2",
"PhotoUrls": ["klklklwewe", "oioioioiinmnmnm"]
}
]