Quantcast
Channel: Postmanタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 470

人間のための http リクエスト検証サービス httpbin.org

$
0
0
意図した http リクエストが送信できているかを検証するのに便利な httpbin.org を紹介します。 (※ httpbin.org は "ほにゃらら for Humans"のフレーズでお馴染みの Kenneth Reitz が作りました。) 意図した http リクエストが送信できなくて困ることはないですか? 私はとてもあります。 http クライアントは他種多用です。 私は Python と js で開発をする人ですが、 requests, axios, cURL, postman, http リクエストを実行してくれるノーコードサービス, etc... と多くの http クライアントを使っています。 どのような設定をしたら、意図したリクエストが送れるかを正確に把握できていません。 httpbin.org はどのようなリクエストが送信されたかを response で返してくれる https://httpbin.org にリクエストを送れば以下のようにリクエスト内容を返却してくれます。 (method によってエンドポイントが異なるので注意です。) $ curl "https://httpbin.org/get?name=hoge" { "args": { "name": "hoge" }, "headers": { "Accept": "*/*", "Host": "httpbin.org", "User-Agent": "curl/7.64.1", "X-Amzn-Trace-Id": "Root=1-61f54cd0-01a05f18402690eb3be67b7a" }, "origin": "<your ip address>", "url": "https://httpbin.org/get?name=hoge" } $ curl -X POST -H "Content-Type: application/json" -d '{"name":"太郎", "age":"30"}' -H 'Authorization: Bearer <token>' https://httpbin.org/post { "args": {}, "data": "{\"name\":\"\u592a\u90ce\", \"age\":\"30\"}", "files": {}, "form": {}, "headers": { "Accept": "*/*", "Authorization": "Bearer <token>", "Content-Length": "29", "Content-Type": "application/json", "Host": "httpbin.org", "User-Agent": "curl/7.64.1", "X-Amzn-Trace-Id": "Root=1-61f54b74-17c581213c86478601e4c9ba" }, "json": { "age": "30", "name": "\u592a\u90ce" }, "origin": "<your ip address>", "url": "https://httpbin.org/post" } 外部サービスにリクエストを送ることに抵抗がある場合は docker コンテナを使っても良いでしょう。 リンク https://kennethreitz.org https://github.com/kennethreitz https://hub.docker.com/r/kennethreitz/httpbin/

Viewing all articles
Browse latest Browse all 470

Trending Articles