はじめに
よく使うcurlコマンドをまとめました。
今後も使用する機会があれば追記します。
APIGatewayのヘッダー確認
SSL接続で証明書エラーをスキップ
curl -k https://対象のURL
HTTPメソッドの指定(-X)
curl -X PUT http://対象のURL
HTTPレスポンスヘッダーの取得(-I)
curl -I http://対象のURL
CloudFrontオリジン指定とパスパターン設定が済んでいると
URLはCloudFrontのドメイン指定でOK
https://xxxxxx.com/api/resource-name
curl -k -I -X POST -H "Content-Type: application/json" -H "Accept: application/json" https://api-id.execute-api.region.amazonaws.com/stage/
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 223
Connection: keep-alive
Date: Tue, 13 Jan 2026 11:40:18 GMT
X-Amzn-Trace-Id: Root=xxxxxxxxxx
x-amzn-RequestId: xxxxx-xxxx-xxxx-xxx-xxxxx
Access-Control-Allow-Origin: https://xxxxx.com
x-amz-apigw-id: xxxx_xxxxxx
X-Cache: Miss from cloudfront
Via: 1.1 xxxxxxxxxx.cloudfront.net (CloudFront)
X-Amz-Cf-Pop: xxxx-xx
X-Amz-Cf-Id: xxxxxxxxxxx
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=xxxxxx
APIGateway疎通確認
HTTPヘッダにHEADERを追加(-H)
-H "Content-Type: application/json"
POSTリクエストとしてフォームを送信(-d)
-d {"param":"aaaaa"}"
curl -X POST -k -H "Content-Type: application/json" -H "Accept: application/json" -d "{\"param\":\"aaaaa\"}" https://xxxxxxx/dev/resource-name