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?

More than 3 years have passed since last update.

IntelliJ IDEAのHTTPクライアントで、マルチパートのパラメータやファイルを渡す

Posted at

概要

RubyMineなどのJetBrains系IDEにはREST APIを扱うためのHTTP Clientがついている。
標準的な説明は公式サイトに載っているが、複数のパラメータを渡すときどうすればいいのかが明記されてない気がしたので、そのメモ。

記述方法

rest-api.http
POST http://localhost/api/v1/upload_image_with_product_id/
Content-Type: multipart/form-data; boundary=WebAppBoundary

--WebAppBoundary
Content-Disposition: form-data; name="product_id"

114514
--WebAppBoundary--

--WebAppBoundary
Content-Disposition: form-data; name="user_id"

810
--WebAppBoundary--

--WebAppBoundary
Content-Disposition: form-data; name="memo"

これこれこういう画像です。
--WebAppBoundary--

--WebAppBoundary
Content-Disposition: form-data; name="file"; filename="comic.png"

< c:\temp\comic.png

###
--WebAppBoundary--

単純にパラメータ欄をそれぞれ作ってあげればいいらしい。

便利な操作

テンプレート展開

HTTPクライアントの編集画面で、ctrl+J (macだと⌘+Jかな?)を押すと、リクエストのテンプレートが表示される。
もちろん直接 mptp(TAB)とかでも展開できる。

image.png

cURLに変換してコピー

リクエストを右クリックして出てくるメニューでは、curlコマンドに変換してクリップボードにコピーできる。地味に便利。

image.png

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?