Add method
    • PDF

    Add method

    • PDF

    Article summary

    Available in Classic and VPC

    Set up and add a method to the API resource created.

    Request

    The following describes the request format for the endpoint. The request format is as follows:

    MethodURI
    POST/products/{product-id}/apis/{api-id}/resources/{resource-id}/methods

    Request headers

    For headers common to API Gateway, see API Gateway common request headers.

    Request path parameters

    The following describes the parameters.

    FieldTypeRequiredDescription
    product-idStringRequiredProduct ID that the API belongs to
    api-idStringRequiredID of the API whose method you want to add
    resource-idStringRequiredID of the target resource in the API

    Request syntax

    The request syntax is as follows.

    {
      "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"
      }
    }
    

    Request body

    The following describes the request body.

    FieldTypeRequiredDescription
    methodNameStringRequiredMethod type
    • ANY | GET | POST | PUT | DELETE | PATCH | OPTIONS | HEAD
    methodDescriptionStringOptionalMethod description
    • 0 - 300 characters
    mockEndPointStringConditionalEndpoint type that returns the value set in the API Gateway
    • Select one from mockEndPoint, ncpEndPoint, and httpEndPoint
    mockEndPoint.httpStatusIntegerConditionalResponse status code
    • Required when selecting the mockEndPoint type
    • Equivalent to the Response Status Code in HTTP
    mockEndPoint.responseStringOptionalData to display in the response
    • 0 - 1500 characters
    mockEndPoint.headersMap<String, String>OptionalHeader to include in the response
    • Header key, value form
    ncpEndPointStringConditionalEndpoint type that returns a value using a service of NAVER Cloud Platform
    • Select one from mockEndPoint, ncpEndPoint, and httpEndPoint
    ncpEndPoint.serviceStringConditionalService on NAVER Cloud Platform to use for returning responses
    • Cloud Functions service can be used
    • Required when selecting the ncpEndPoint type
    ncpEndPoint.regionStringConditionalSupported Region code of the Cloud Functions serviceul>
  • KR | JPN | SGN
  • Required when selecting the ncpEndPoint type
  • ncpEndPoint.actionIdStringConditionalAction ID of the Cloud Functions service
    • Required when selecting the ncpEndPoint type
    ncpEndPoint.actionNameStringConditionalAction name of the Cloud Functions service
    • Required when selecting the ncpEndPoint type
    ncpEndPoint.streamBooleanConditionalWhether to use the stream feature
    • true | false
      • true: The stream feature is used
      • false: The stream feature is not used
    • Required when selecting the ncpEndPoint type
    ncpEndPoint.methodStringOptionalMethod type to request from the Cloud Functions service
    • ANY | GET | POST | PUT | DELETE | PATCH | OPTIONS | HEAD
    ncpEndPoint.urlStringConditionalURL path of the Cloud Functions service
    • Required when selecting the ncpEndPoint type
    httpEndPointStringConditionalEndpoint type that returns the result of a call to an HTTP(S) endpoint
    • Select one from mockEndPoint, ncpEndPoint, and httpEndPoint
    httpEndPoint.methodStringConditionalMethod type to request from the backend server
    • ANY | GET | POST | PUT | DELETE | PATCH | OPTIONS | HEAD
    • Required when selecting the httpEndPoint type
    httpEndPoint.streamBooleanConditionalWhether to use the stream feature
    • true | false
      • true: The stream feature is used. Use it for requests that are file uploads in nature. Response time is limited to 5 minutes and request size to 100 MB
      • false: The stream feature is not used. Response time is limited to 30 seconds and request size to 10 MB
    • Required when selecting the httpEndPoint type
    httpEndPoint.urlStringConditionalURL path to request to the backend server
    • Exclude domains
    • The query string and headers defined in the resource path variable and request parameters can be used. Define using "{}" when used.
    • 1 - 1500 characters
    • Required when selecting the httpEndPoint type
    requiredApiKeyStringRequiredAPI key usage information
    requiredApiKey.requiredBooleanRequiredWhether to use API key
    • true | false
      • true: API key is used
      • false: API key is not used. Product subscription method and usage plan are not applied
    validationStringRequiredValidity check information
    validation.typeStringRequiredValidity check range
    • NONE | QUERYSTRING_HEADERS
      • NONE: No validaty check is run
      • QUERYSTRING_HEADERS: Run validaty check for the query string and headers
    validation.headersList<String>ConditionalList of required headers subject to validity check
    • Enter when selecting QUERYSTRING_HEADERS
    validation.queryStringsList<String>ConditionalList of required query strings subject to validity check
    • Enter when selecting QUERYSTRING_HEADERS
    authenticationStringRequiredAuthentication information
    authentication.platformStringRequiredSet authentication method
    • NONE | IAM | AUTHORIZER
      • NONE: no authentication
      • IAM: Use IAM authentication provided by NAVER Cloud Platform
      • AUTHORIZER: Use a pre-created authorizer
    authentication.authorizerIdStringConditionalID of the authorizer to use when using the authorizer as the authentication method

    Request example

    The following is a sample request.

    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"
    }'
    

    Response

    The following describes the response format.

    Response syntax

    The response syntax is as follows.

    {
      "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"
        }
      } ]
    }
    

    Response status codes

    For response status codes common to API Gateway, see API Gateway response status codes.

    Response example

    The following is a sample response.

    {
      "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"
        }
      ]
    }
    

    Was this article helpful?

    What's Next
    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.