I have a Web API that allows basic CRUD using GET/POST/PUT, but also contains subobjects that are accessed through /apipath/MyObject/{objectId}/SubObject/{subObjectId}
Adding a subObject uses this method
[HttpPost]
[Route("{id}/Members")]
[Produces(typeof(TeamMember))]
public IActionResult AddTeamMember(Guid id, [FromBody] TeamMember teamMember)
{
//some processing here.
return CreatedAtAction(nameof(GetMember), new { id, memberId = teamMember.Id }, teamMember);
}
The GetMember method looks like this
[HttpGet]
[Route("{id}/Members/{memberId}")]
public IActionResult GetMember(Guid id, Guid memberId)
{ //processing here
}
Calling CreatedAtAction in AddTeamMember throws a
'System.InvalidOperationException': No route matches the supplied values.
If I change the Route tag of GetMember to exclude the Members part, it works. So, how do I tell CreatedAtAction that there's supposed to be a Members in between id and memberId?