3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Visual Studio Codeの拡張機能であるREST Clientを使ってみる

Posted at

概要

APIのリクエストレスポンスの確認としてPostmanを使っているが、
Visual Studio Code(VSCode)の拡張機能であるREST Clientが便利だったので
使い方のメモを記載する。

手順

1.REST Clientのインストール

拡張機能の検索から「REST」入力すると一番上に表示される。

スクリーンショット 2021-04-06 0.47.40.png

インストールボタンを押してREST Clientの拡張機能を取り込む
スクリーンショット 2021-04-06 0.46.03.png

2.REST Clientを使ったGETリクエスト

リクエスト操作を行うために、.httpファイルを作成する。
本記事では、sample.httpファイルを用意し、記載をしていく。

sample.http

GET http://localhost:3000/api/v1/tasks HTTP/1.1

たまたまローカル環境に、Rails APIで起動しているアプリがあったので、GETリクエストをする。
リクエストURLを記載し、上に書かれた「Send Request」を押す。

結果

スクリーンショット 2021-04-06 0.59.31.png

スクリーンショット 2021-04-06 0.59.45.png

リクエストの結果として、Response画面にレスポンスデータが表示された。

3.REST Clientを使ったPOSTリクエスト

sample.httpにPost処理を記載する。

sample.https

POST http://localhost:3000/api/v1/tasks HTTP/1.1
content-type: application/json

{
    "title": "sample",
    "description": "これはサンプルデータです。"
}

結果

スクリーンショット 2021-04-06 1.08.05.png

まとめ

今回のREST Clientは新くアプリをインストールすることはせずにVSCodeの拡張機能としてAPIの確認をしてみました。
拡張機能として使えるのはありがたいです。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?