Sunday, December 10, 2017

InvalidOperationException: The constraint entry 'whatever' - 'string' on the route 'api/Foo/{whatever:string}' could not be resolved by the constraint resolver of type 'DefaultInlineConstraintResolver'.

[HttpPut("{whatever:string}")]

 
 

...needs to become...

[HttpPut("{whatever}")]

 
 

...to fix this error. Specify the type for everything but string. This came up today while I struggled to pass an object to a .NET Core REST Controller. I was missing:

[FromBody]

 
 

...and really the action attribute just needed to be:

[HttpPut]

No comments:

Post a Comment