Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PUTとPOSTどっち使う?
Search
Hank Ehly
June 23, 2022
Technology
1.2k
0
Share
PUTとPOSTどっち使う?
https://qiita.com/hankehly/items/ed7e699ebe89f14b2ff7
Hank Ehly
June 23, 2022
More Decks by Hank Ehly
See All by Hank Ehly
Fivetranでデータ移動を自動化する
hankehly
0
650
Celeryの紹介と本番運用のTips
hankehly
0
1.6k
ChatGPTを活用した 便利ツールの紹介
hankehly
1
1.4k
Efficient Energy Analytics with Airflow, Spark, and MLFlow
hankehly
0
400
Deferrable Operators入門
hankehly
0
750
【初心者/ハンズオン】Dockerコンテナの基礎知識
hankehly
0
590
Compositeパターン: オブジェクトの階層関係をエレガントに表現する方法
hankehly
0
350
10/29 Airflowの基礎を学ぶハンズオンワークショップ
hankehly
0
300
システム/データ品質保証のための Airflow 活用法
hankehly
0
670
Other Decks in Technology
See All in Technology
Javaで学ぶSOLID原則
negima
1
250
Databricks 月刊サービスアップデート 2026年05月号
tyosi1212
0
130
ITエンジニアを取り巻く環境とキャリアパス / A career path for Japanese IT engineers
takatama
4
1.8k
Spring Boot における AOT Cache 活用テクニックと 起動時間改善事例
ntt_dsol_java
0
180
探して_入れて_作って_使う_Agent_Skills___LT.pdf
peintangos
2
120
AI Adaptable なテストを整える工夫 / Ways to Make Your Tests AI-Adaptable
bitkey
PRO
2
190
管理アカウント単一運用からAWS Organizationsに移行するの大変で滅
hiramax
0
370
プラットフォームエンジニア ワークショップ/ platform-workshop
databricksjapan
0
150
テストコードのないプロジェクトにテストを根付かせる
tttol
1
240
TROCCOで始めるクラウドコストを民主化するためのFinOps
tk3fftk
2
500
AIプラットフォームを運用し続けるための可観測性
tanimuyk
4
830
Sony_KMP_Journey_KotlinConf2026
sony
1
190
Featured
See All Featured
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
180
4 Signs Your Business is Dying
shpigford
187
22k
Optimising Largest Contentful Paint
csswizardry
37
3.7k
Everyday Curiosity
cassininazir
0
220
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
Visualization
eitanlees
152
17k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
460
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
260
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
200
How to Think Like a Performance Engineer
csswizardry
28
2.6k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.1k
sira's awesome portfolio website redesign presentation
elsirapls
0
270
Transcript
PUTとPOSTどっち使う? qiita.com/hankehly > PUTとPOSTどっち使う?
自己紹介 • Hank Ehly (ハンク イーリー) • ENECHANGE株式会社 • qiita.com/hankehly
• connpass.com/user/hankehly • github.com/hankehly • speakerdeck.com/hankehly qiita.com/hankehly > PUTとPOSTどっち使う?
アジェンダ 1. PUTとPOSTの違い 2. POST 3. PUT qiita.com/hankehly > PUTとPOSTどっち使う?
百億%忘れてい るぜ
1 0 意識している あまり意識しない チャットに投稿してください Web APIを開発する上で PUTとPOSTの違いを…
PUTとPOSTの違い qiita.com/hankehly > PUTとPOSTどっち使う?
• リクエストに同封されているデータの意図 The fundamental difference between the POST and PUT
methods is highlighted by the different intent for the enclosed representation (RFC7231) • 使い分けることで、表現力の高い、理解しやすい Web API が作れる PUTとPOSTの違い qiita.com/hankehly > PUTとPOSTどっち使う?
PUTとPOSTの違い リソース 新規作成 バッチ処理開始 データ削除 POST PUT リソース 置き換え ファイル
アップロード qiita.com/hankehly > PUTとPOSTどっち使う?
POST
POST • 受け取ったデータで何してもおかしくない • 汎用的 リクエスト レスポンス DBレコードを INSERT する
201 (Created) ファイルを削除する 204 (No Content) 非同期処理を開始する 202 (Accepted) キャッシュされたリソースにリダイレクトする 303 (See Other) qiita.com/hankehly > PUTとPOSTどっち使う? • 一般的に冪等性がないため、キャッシュの対象にならない
POST /articles HTTP/1.1 { "name": "foo", "author": "tanaka", "content": "hello
world" } HTTP/1.1 201 Created Location: http://example.com/articles/12 POST • リソースの新規作成に使うことが多い qiita.com/hankehly > PUTとPOSTどっち使う?
POST • リソースの新規作成に使うことが多い POST /articles HTTP/1.1 { "name": "foo", "author":
"tanaka", "content": "hello world" } HTTP/1.1 201 Created Location: http://example.com/articles/12 qiita.com/hankehly > PUTとPOSTどっち使う?
POST • リソースの新規作成に使うことが多い POST /articles HTTP/1.1 { "name": "foo", "author":
"tanaka", "content": "hello world" } HTTP/1.1 201 Created Location: http://example.com/articles/12 qiita.com/hankehly > PUTとPOSTどっち使う?
PUT
PUT • 対象リソースの置き換え(丸ごと) • どのリソースを置き換えるか知っている必要がある ◦ PUT /articles/12 • 冪等性
qiita.com/hankehly > PUTとPOSTどっち使う?
PUT INSERT INTO articles (id, name, author) VALUES (12, "foo",
"tanaka") ON CONFLICT (id) DO UPDATE SET name = "foo", author = "tanaka" PUTリクエストをSQLに例えたら qiita.com/hankehly > PUTとPOSTどっち使う?
PUT INSERT INTO articles (id, name, author) VALUES (12, "foo",
"tanaka") ON CONFLICT (id) DO UPDATE SET name = "foo", author = "tanaka" PUT /articles/12 HTTP/1.1 { "name": "foo", "author": "tanaka" } PUTリクエストをSQLに例えたら qiita.com/hankehly > PUTとPOSTどっち使う?
• PUTとPOSTの違いはリクエストデータ意図です • POSTは、1つの決まった使い方がなく、汎用的に活用できる ◦ 何かを「新規作成」するためによく使われる • PUTは、リソースの状態を丸ごと置き換える • 違いを意識することで、より表現力の高い
API 開発ができる まとめ qiita.com/hankehly > PUTとPOSTどっち使う? POST /articles/12 意図が曖昧(何するの?) PUT /articles/12 意図が明確になる
ご清聴ありがとうございます qiita.com/hankehly > PUTとPOSTどっち使う?