MENU
      メソッドの追加

        メソッドの追加


        記事の要約

        Classic/VPC環境で利用できます。

        作成した APIリソースにメソッドを設定して追加します。

        リクエスト

        リクエスト形式を説明します。リクエスト形式は次の通りです。

        メソッドURI
        POST/products/{product-id}/apis/{api-id}/resources/{resource-id}/methods

        リクエストヘッダ

        API Gatewayで共通して使用されるヘッダの詳細は、API Gatewayのリクエストヘッダをご参照ください。

        リクエストパスパラメータ

        パラメータの説明は次の通りです。

        フィールドタイプ必須の有無説明
        product-idStringRequiredAPIが属する Product ID
        api-idStringRequiredメソッド追加対象の API ID
        resource-idStringRequiredAPI内対象リソースの ID

        リクエスト構文

        リクエスト構文は次の通りです。

        {
          "methodName" : "ANY",
          "methodDescription" : "methodDescription",
          "mockEndPoint" : {
            "httpStatus" : 0,
            "response" : "response",
            "headers" : {
              "key" : "value"
            }
          },
          "ncpEndPoint" : {
            "service" : "service",
            "region" : "KR",
            "actionId" : "actionId",
            "actionName" : "actionName",
            "stream" : true,
            "method" : "ANY",
            "url" : "url"
          },
          "httpEndPoint" : {
            "method" : "ANY",
            "stream" : true,
            "url" : "url"
          },
          "requiredApiKey" : {
            "required" : true
          },
          "validation" : {
            "type" : "NONE",
            "headers" : [ "headers" ],
            "queryStrings" : [ "queryStrings" ]
          },
          "authentication" : {
            "platform" : "NONE",
            "authorizerId" : "authorizerId"
          }
        }
        JSON

        リクエストボディ

        リクエストボディの説明は次の通りです。

        フィールドタイプ必須の有無説明
        methodNameStringRequiredメソッドタイプ
        • ANY | GET | POST | PUT | DELETE | PATCH | OPTIONS | HEAD
        methodDescriptionStringOptionalメソッドの説明
        • 0~300文字
        mockEndPointStringConditionalAPI Gatewayで設定した値を返すエンドポイントタイプ
        • mockEndPointncpEndPointhttpEndPointの中から択一
        mockEndPoint.httpStatusIntegerConditionalレスポンスステータスコード
        • mockEndPointタイプ選択時、必ず入力
        • HTTPの Response Status Codeに対応する値
        mockEndPoint.responseStringOptionalレスポンスに表示するデータ
        • 0~1500文字
        mockEndPoint.headersMap<String、String>Optionalレスポンスに含めるヘッダ
        • ヘッダ Key、Value形式
        ncpEndPointStringConditionalNAVERクラウドプラットフォームのサービスを利用して値を返すエンドポイントタイプ
        • mockEndPointncpEndPointhttpEndPointの中から択一
        ncpEndPoint.serviceStringConditionalレスポンスの返しに使用する NAVERクラウドプラットフォームのサービス
        • Cloud Functionsサービスを利用可能
        • ncpEndPointタイプ選択時、必ず入力
        ncpEndPoint.regionStringConditionalCloud Functionsサービスのサポートリージョンコード
        • KR | JPN | SGN
        • ncpEndPointタイプ選択時、必ず入力
        ncpEndPoint.actionIdStringConditionalCloud Functionsサービスのアクション ID
        • ncpEndPointタイプ選択時、必ず入力
        ncpEndPoint.actionNameStringConditionalCloud Functionsサービスのアクション名
        • ncpEndPointタイプ選択時、必ず入力
        ncpEndPoint.streamBooleanConditionalStream機能の使用有無
        • true | false
          • true: Stream機能を使用
          • false: Stream機能を使用しない
        • ncpEndPointタイプ選択時、必ず入力
        ncpEndPoint.methodStringOptionalCloud Functionsサービスでリクエストするメソッドタイプ
        • ANY | GET | POST | PUT | DELETE | PATCH | OPTIONS | HEAD
        ncpEndPoint.urlStringConditionalCloud Functionsサービスの URLパス
        • ncpEndPointタイプ選択時、必ず入力
        httpEndPointStringConditionalHTTP(S)エンドポイントの呼び出し結果を返すエンドポイントタイプ
        • mockEndPointncpEndPointhttpEndPointの中から択一
        httpEndPoint.methodStringConditionalバックエンドサーバにリクエストするメソッドタイプ
        • ANY | GET | POST | PUT | DELETE | PATCH | OPTIONS | HEAD
        • httpEndPointタイプ選択時、必ず入力
        httpEndPoint.streamBooleanConditionalStream機能の使用有無
        • true | false
          • true: Stream機能を使用。ファイルアップロードのようなリクエストの場合、使用。レスポンス時間は5分、リクエストサイズは最大100MBに制限。
          • false: Stream機能を使用しない。レスポンス時間は30秒、リクエストサイズは10MBに制限。
        • httpEndPointタイプ選択時、必ず入力
        httpEndPoint.urlStringConditionalバックエンドサーバにリクエストする URLパス
        • ドメインを除く
        • リソースパス変数とリクエストパラメータで定義したクエリ文字列とヘッドを使用可能。使用時は「{}」を使って定義。
        • 1~1500文字
        • httpEndPointタイプ選択時、必ず入力
        requiredApiKeyStringRequiredAPI key使用情報
        requiredApiKey.requiredBooleanRequiredAPI keyの使用有無
        • true | false
          • true: API keyを使用
          • false: API keyを使用しない。Productサブスクリプション方法と Usage Planが適用されない
        validationStringRequired有効性検査情報
        validation.typeStringRequired有効性検査の範囲
        • NONE | QUERYSTRING_HEADERS
          • NONE: 有効性検査を実行しない
          • QUERYSTRING_HEADERS: クエリ文字列とヘッドの有効性検査を実行
        validation.headersList<String>Conditional有効性検査対象の必須ヘッダリスト
        • QUERYSTRING_HEADERS選択時、入力
        validation.queryStringsList<String>Conditional有効性検査対象の必須クエリ文字列リスト
        • QUERYSTRING_HEADERS選択時、入力
        authenticationStringRequired認証情報
        authentication.platformStringRequired認証方法の設定
        • NONE | IAM | IAM_AUTHORIZATION | AUTHORIZER
          • NONE: 認証を使用しない
          • IAM: NAVERクラウドプラットフォームが提供する IAM認証を使用
          • IAM_AUTHORIZATION: NAVERクラウドプラットフォームが提供する IAM認証/認可を使用
          • AUTHORIZER: 予め作成済みの Authorizerを使用
        authentication.authorizerIdStringConditional認証方法として Authorizerを使用する場合、その Authorizerの ID

        リクエスト例

        リクエストのサンプルコードは次の通りです。

        curl --location --request POST 'https://apigateway.apigw.ntruss.com/api/v1/products/********o9/apis/cvcohvd2xj/resources/p1hiuvmwv3/methods' \
        --header 'x-ncp-apigw-timestamp: {Timestamp}' \
        --header 'x-ncp-iam-access-key: {Access Key}' \
        --header 'x-ncp-apigw-signature-v2: {API Gateway Signature}' \
        --header 'Content-Type: application/json' \
        --data '{
          "methodName": "GET",
          "httpEndPoint": {
            "stream": true,
            "method": "ANY",
            "url": "/sample22"
          },
          "validation": {
            "type": "NONE",
            "queryStrings": [
              "string"
            ],
            "headers": [
              "string"
            ]
          },
          "authentication": {
            "platform": "NONE"
          },
          "requiredApiKey": {
            "required": true
          },
          "methodDescription": "string"
        }'
        Curl

        レスポンス

        レスポンス形式を説明します。

        レスポンス構文

        レスポンス構文は次の通りです。

        {
          "methods" : [ {
            "methodDescription" : "methodDescription",
            "resourceId" : "resourceId",
            "useBodyWhenFormData" : true,
            "modifier" : "modifier",
            "resourcePath" : "resourcePath",
            "methodName" : "ANY",
            "ncpEndPoint" : {
              "method" : "ANY",
              "stream" : true,
              "service" : "service",
              "actionId" : "actionId",
              "region" : "KR",
              "url" : "url",
              "actionName" : "actionName"
            },
            "requiredApiKey" : {
              "required" : true
            },
            "mockEndPoint" : {
              "headers" : {
                "key" : "headers"
              },
              "response" : "response",
              "httpStatus" : 0
            },
            "produces" : "produces",
            "tenantId" : "tenantId",
            "consumers" : "consumers",
            "apiId" : "apiId",
            "validation" : {
              "headers" : [ "headers" ],
              "queryStrings" : [ "queryStrings" ],
              "type" : "NONE"
            },
            "authentication" : {
              "authorizerId" : "authorizerId",
              "platform" : "NONE"
            },
            "httpEndPoint" : {
              "method" : "ANY",
              "stream" : true,
              "url" : "url"
            }
          } ]
        }
        JSON

        レスポンスステータスコード

        API Gatewayで共通して使用されるレスポンスステータスコードの詳細は、API Gatewayのレスポンスステータスコードをご参照ください。

        レスポンス例

        レスポンスのサンプルコードは次の通りです。

        {
          "methods": [
            {
              "apiId": "cvcohvd2xj",
              "resourceId": "p1hiuvmwv3",
              "methodDescription": "string",
              "methodName": "GET",
              "useBodyWhenFormData": false,
              "validation": {
                "type": "NONE",
                "queryStrings": [
                  "string"
                ],
                "headers": [
                  "string"
                ]
              },
              "authentication": {
                "platform": "NONE"
              },
              "requiredApiKey": {
                "required": true
              },
              "httpEndPoint": {
                "stream": true,
                "method": "GET",
                "url": "/sample22"
              },
              "tenantId": "********65ec41039ce6668c2058b8a9",
              "modifier": "********-7fcd-11ec-a6ba-246e9659184c"
            }
          ]
        }
        JSON

        この記事は役に立ちましたか?

        Changing your password will log you out immediately. Use the new password to log back in.
        First name must have atleast 2 characters. Numbers and special characters are not allowed.
        Last name must have atleast 1 characters. Numbers and special characters are not allowed.
        Enter a valid email
        Enter a valid password
        Your profile has been successfully updated.