1
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?

Postman って?

PostmanはAPIのテストをするためのツールです。
ただテストをするだけじゃなくて、APIのドキュメントを作れたり組織を作って共有できたりと、様々な機能があります。

使い方

今回はこのサイトを使ってダミーデータを作成して、Jsonのデータを送信するAPIをPostmanでテストしてみます。

1.HTTPリクエストを作成する

左上の新規ボタンを押しましょう。
そうすると以下のようなダイアログが出てくるので、HTTPを選択します。
image.png

2.Jsonデータを作成する

以下のような画面になったでしょうか。
image.png

ここまでできたら、ボディを選択し、Rawを選択します。
image.png

テキストエディタのような画面が登場したらOKです。
そしてここにJsonデータを入力します。
今回のダミーのAPIは以下のようなJsonデータを受け取るのでコピーして使ってください。

{
  "userId": 1,
  "products": [
    {
      "id": 98,
      "quantity": 4
    },
    {
      "id": 144,
      "quantity": 1
    }
  ]
}

3.リクエストを送信する

左上の GET と表示されているところをクリックして
image.png

POST に変更します。
image.png

4.リクエストを送信する

ここまで全てできていれば以下のような画面になるはずです。
最後に送信ボタンを押してリクエストを送信します。
image.png

こんなメッセージが帰ってきたら成功です。

{
    "id": 51,
    "products": [
        {
            "id": 98,
            "title": "Rolex Submariner Watch",
            "price": 13999.99,
            "quantity": 4,
            "total": 55999.96,
            "discountPercentage": 0.82,
            "discountedPrice": 55541,
            "thumbnail": "https://cdn.dummyjson.com/products/images/mens-watches/Rolex%20Submariner%20Watch/thumbnail.png"
        },
        {
            "id": 144,
            "title": "Cricket Helmet",
            "price": 44.99,
            "quantity": 1,
            "total": 44.99,
            "discountPercentage": 10.75,
            "discountedPrice": 40,
            "thumbnail": "https://cdn.dummyjson.com/products/images/sports-accessories/Cricket%20Helmet/thumbnail.png"
        }
    ],
    "total": 56044.95,
    "discountedTotal": 55581,
    "userId": 1,
    "totalProducts": 2,
    "totalQuantity": 5
}
1
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
1
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?