10
3

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.

[VSCode][Rest Client]フォーム形式のPOSTリクエストを送信する

Last updated at Posted at 2020-05-19

VSCodeプラグインのRest Clientを利用した場合のフォーム形式の送信のやり方メモ。

Rest ClientとはHTTPリクエストをテキストベースで管理できる優れもののプラグイン。
VS Code上でHTTPリクエストを送信し、VS Code上でレスポンスを確認できる「REST Client」拡張の紹介 - Qiita

リクエスト例

testdata.http
POST http://example.com/target.php HTTP/1.1
content-type: application/x-www-form-urlencoded

id=1234
&name=yamada_taro
&age=18
ポイント
  • リクエストヘッダのContent-Typeを application/x-www-form-urlencodedmultipart/form-data に指定する。
  • キーと値を=でつなぐ。複数項目は&でつなぐ。
  • 空白を入れたりコメントを入れたりするとエラーになる。
  • PHPで受け取る際は$_POST['id']で取得できる。

参考

Support multiline request body for x-www-form-urlencoded · Issue #169 · Huachao/vscode-restclient · GitHub

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?