You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi I may be using the package incorrectly but I am trying to create API endpoints with a single object and bind from the body and the route to my single object. Reading the documentation I assume for my situation if I installed the package and added it in Startup when configuring services my scenario would work out the box without any additional decoration. I have a endpoint like this
``
[HttpPost("todolist/{listId}/todo")]
public async Task<ActionResult> CreateTodo(CreateTodoItemCommand command)
{
//some code
}
``
My command object looks like this
``
public class CreateTodoItemCommand : IRequest
{
public int ListId { get; set; }
public string Title { get; set; } = string.Empty;
public string Note { get; set; } = string.Empty;
}
``
Title and note are bound from the body of the request and I want ListId to be bound from the route. I had assumed as I had a single source for each property I would not need additional binding attributes on either the controller method or the contract. However this does not work and ListId is never bound. Title and Note are bound without issue. I have tried playing around with global fallback order but this does not seem to do anything. The only way I can get this to work is to add the HybridBindProperty with a source of route on the ListId property.
Ideally I dont want to add a reference to hybridbinding into my contract repository and did not think I would need to in this simple use case. The documents seem to suggest that if you have a single object on the controller method and that the standard order for binding is acceptable this should just work. Am I doing something wrong or is my scenario not supported. Any help is much appreciated. Regards
The text was updated successfully, but these errors were encountered:
May you post a sample project as a ZIP-file? I can't duplicate this particular problem... I'm using the sample project from this repo. and made some modifications based on your explanation.
Hi I may be using the package incorrectly but I am trying to create API endpoints with a single object and bind from the body and the route to my single object. Reading the documentation I assume for my situation if I installed the package and added it in Startup when configuring services my scenario would work out the box without any additional decoration. I have a endpoint like this
``
``
My command object looks like this
``
public class CreateTodoItemCommand : IRequest
{
public int ListId { get; set; }
``
Title and note are bound from the body of the request and I want ListId to be bound from the route. I had assumed as I had a single source for each property I would not need additional binding attributes on either the controller method or the contract. However this does not work and ListId is never bound. Title and Note are bound without issue. I have tried playing around with global fallback order but this does not seem to do anything. The only way I can get this to work is to add the HybridBindProperty with a source of route on the ListId property.
Ideally I dont want to add a reference to hybridbinding into my contract repository and did not think I would need to in this simple use case. The documents seem to suggest that if you have a single object on the controller method and that the standard order for binding is acceptable this should just work. Am I doing something wrong or is my scenario not supported. Any help is much appreciated. Regards
The text was updated successfully, but these errors were encountered: