Click here to Skip to main content
15,868,141 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I work on csharp webapi .net core 6
i need to pass number integer id with object
but i don't know how to do on post man put method request

[HttpPut("{id}")]
      public async Task<IActionResult> Update(int id, UpdateItemCommand command)
      {
          if (id != command.Id)
          {
              return BadRequest();
          }
          return Ok(await Mediator.Send(command));
      }


this is my url
https://localhost:7235/api/items/[^]

What I have tried:

on post man i add this script on body
{
    "itemId": 4,
    "itemNameAR": "قلم",
    "itemNameEN": "pen2",
    "costTypeId": 1,
    "minLimitQunatity": 1,
    "costAccountID": 1,
    "departmentID": 1,
    "itemCategoryId": 1,
    "description": "1",
    "hasExpireDate": true,
    "isActive": true,
    "createdBy": 1,
    "modifiedBy": 1,
    "createdDate": "0001-01-01T00:00:00",
    "modifiedDate": "0001-01-01T00:00:00",
    "itemattribute": null
}
Posted
Updated 24-Nov-22 22:38pm

1 solution

The ID parameter is part of the route. The URL for your request needs to look something like:
https://localhost:7235/api/items/42
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900