Add method

Prev Next

Available in Classic and VPC

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

Request

This section describes the request format. The method and URI are as follows:

Method URI
POST /api/v1/products/{product-id}/apis/{api-id}/resources/{resource-id}/methods

Request headers

For information about the headers common to all API Gateway APIs, see API Gateway request headers.

Request path parameters

You can use the following path parameters with your request:

Field Type Required Description
product-id String Required ID of product the API belongs to
api-id String Required ID of the API to which the method will be added
resource-id String Required ID 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

You can include the following data in the body of your request:

Field Type Required Description
methodName String Required Method type
  • ANY | GET | POST | PUT | DELETE | PATCH | OPTIONS | HEAD
methodDescription String Optional Description of the method
  • 0-2000 characters
mockEndPoint String Conditional Endpoint type that returns the value set in API Gateway.
  • Select one among mockEndPoint, ncpEndPoint, and httpEndPoint.
mockEndPoint.httpStatus Integer Conditional Response status code
  • Required when selecting the mockEndPoint type
  • Value corresponding to the response status code of HTTP
mockEndPoint.response String Optional Data to display in response
  • 0-1500 characters
mockEndPoint.headers Map[String, String] Optional Headers to include in the response
  • Header key, value format
ncpEndPoint String Conditional Endpoint type that returns a value using a service of NAVER Cloud Platform
  • Select one among mockEndPoint, ncpEndPoint, and httpEndPoint.
ncpEndPoint.service String Conditional Service on NAVER Cloud Platform to use for returning responses
  • Cloud Functions can be used.
  • Required when selecting the ncpEndPoint type
ncpEndPoint.region String Conditional Cloud Functions service's supported Region code
  • KR | JPN | SGN
  • Required when selecting the ncpEndPoint type
ncpEndPoint.actionId String Conditional Cloud Functions service's action ID
  • Required when selecting the ncpEndPoint type
ncpEndPoint.actionName String Conditional Cloud Functions service's action name
  • Required when selecting the ncpEndPoint type
ncpEndPoint.stream Boolean Conditional Whether to use the stream feature
  • true | false
    • true: Use the stream feature.
    • false: Disable the stream feature.
  • Required when selecting the ncpEndPoint type
ncpEndPoint.method String Optional Method type to request to the Cloud Functions service
  • ANY | GET | POST | PUT | DELETE | PATCH | OPTIONS | HEAD
ncpEndPoint.url String Conditional URL path of the Cloud Functions service
  • Required when selecting the ncpEndPoint type
httpEndPoint String Conditional Endpoint type that returns the result of calling the HTTP(S) endpoint
  • Select one among mockEndPoint, ncpEndPoint, and httpEndPoint.
httpEndPoint.method String Conditional Method type to request to the backend server
  • ANY | GET | POST | PUT | DELETE | PATCH | OPTIONS | HEAD
  • Required when selecting the httpEndPoint type
httpEndPoint.stream Boolean Conditional Whether to use the Stream feature
  • true | false
    • true: Use the Stream feature. Use it for requests that are file uploads in nature. Response time is limited to 5 minutes, and request size is limited to 100 MB.
    • false: Disable the stream feature. Response time is limited to 30 seconds, and request size is limited to 10 MB.
  • Required when selecting the httpEndPoint type
httpEndPoint.url String Conditional URL path to request to the backend server
  • Domains are excluded.
  • You can use the query string and header defined in the resource path variable and request parameters. Use "{}" to define when using.
  • 1-1500 characters
  • Required when selecting the httpEndPoint type
requiredApiKey String Required API key usage information
requiredApiKey.required Boolean Required Whether API key is used
  • true | false
    • true: API key is used.
    • false: API key is not used. It is not subject to the product subscription method or usage plan.
validation String Required Validity check information
validation.type String Required Validity check scope
  • NONE | QUERYSTRING_HEADERS
    • NONE: no validity check performed
    • QUERYSTRING_HEADERS: validity check for query string and header
validation.headers List[String] Conditional List of required headers subject to validity checks
  • Enter when selecting QUERYSTRING_HEADERS.
validation.queryStrings List[String] Conditional List of required query strings subject to validity checks
  • Enter when selecting QUERYSTRING_HEADERS.
authentication String Required Authentication information
authentication.platform String Required Set the authentication method.
  • NONE | IAM | IAM_AUTHORIZATION | AUTHORIZER
    • NONE: no authentication
    • IAM: IAM authentication provided by the NAVER Cloud Platform
    • IAM_AUTHORIZATION: IAM authentication/authorization provided by NAVER Cloud Platform
    • AUTHORIZER: pre-generated authorizer
authentication.authorizerId String Conditional ID of the authorizer to be used when using authorizer as the authentication method

Request example

The request example is as follows:

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

This section 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 information about the HTTP status codes common to all API Gateway APIs, see API Gateway response status codes.

Response example

The response example is as follows:

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