0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

1️⃣ Postman を準備

  1. 公式サイトから Postman をインストール
    https://www.postman.com/downloads/
  2. インストール後、アカウント作成(無料でOK)

2️⃣ APIサーバーを起動

  1. Visual Studio やターミナルで、プロジェクトのフォルダに移動
  2. ターミナルで以下を実行
dotnet run



3. コンソールに以下のような表示が出ます

Now listening on: https://localhost:7252

3️⃣ Postmanでリクエスト作成

  1. Postmanを開き、左上の 「+ New」 → 「HTTP Request」 をクリック
  2. 上の入力欄に以下を入力
    • Method: POST
    • URL:
https://localhost:7252/api/FireInsurance/calculate

(ポート番号はあなたの環境に合わせる)


3. 「Body」タブをクリック
• raw を選択
• 右横のドロップダウンを JSON に設定
4. 以下のJSONを入力

{
  "StructureType": "木造",
  "Prefecture": "東京都",
  "BuildingAge": 8,
  "BuildingCoverage": 2000,
  "HouseholdCoverage": 500,
  "IncludeEarthquake": true,
  "IncludeFlood": false,
  "Years": 5,
  "Deductible": 100000
}

4️⃣ 送信して結果を確認

  1. 右上の 「Send」 ボタンをクリック
{
  "annualPremium": 96350,
  "totalPremium": 481750,
  "details": "構造: 木造, 地域: 関東, 基本料率: 0.35 %, 建物年数補正: 1.05, オプション補正: 1.3, 免責割引: 0.95"
}

スクリーンショット 2025-08-15 7.34.19.png

ブラウザ上の挙動

HTTP ERROR 405
スクリーンショット 2025-08-15 7.36.19.png

FireInsuranceController の Calculate メソッドには

[HttpPost("calculate")]

と書いてあります。

つまり、このエンドポイントは POSTリクエスト専用 です。
ブラウザでURLを直接開くと、デフォルトで GET リクエストが送られるため、
「メソッドは合ってないよ」という 405 エラーになります。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?