【解決方法】メソッド PUT で API をテストするときに、API に置かれたリクエストを送信する方法は?

プログラミングQA


私はcsharp webapi .net core 6に取り組んでいます
オブジェクトで数値整数 ID を渡す必要があります
しかし、ポストマンプットメソッドリクエストのやり方がわかりません

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

これは私のURLです
https://localhost:7235/api/items/[^]

私が試したこと:

郵便配達員で、このスクリプトを本文に追加します

{
    "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
}

解決策 1

ID パラメータはルートの一部です。 リクエストの URL は次のようにする必要があります。

https://localhost:7235/api/items/42

コメント

タイトルとURLをコピーしました