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
|
methodDescription |
String | Optional | Description of the method
|
mockEndPoint |
String | Conditional | Endpoint type that returns the value set in API Gateway.
|
mockEndPoint.httpStatus |
Integer | Conditional | Response status code
|
mockEndPoint.response |
String | Optional | Data to display in response
|
mockEndPoint.headers |
Map[String, String] | Optional | Headers to include in the response
|
ncpEndPoint |
String | Conditional | Endpoint type that returns a value using a service of NAVER Cloud Platform
|
ncpEndPoint.service |
String | Conditional | Service on NAVER Cloud Platform to use for returning responses
|
ncpEndPoint.region |
String | Conditional | Cloud Functions service's supported Region code
|
ncpEndPoint.actionId |
String | Conditional | Cloud Functions service's action ID
|
ncpEndPoint.actionName |
String | Conditional | Cloud Functions service's action name
|
ncpEndPoint.stream |
Boolean | Conditional | Whether to use the stream feature
|
ncpEndPoint.method |
String | Optional | Method type to request to the Cloud Functions service
|
ncpEndPoint.url |
String | Conditional | URL path of the Cloud Functions service
|
httpEndPoint |
String | Conditional | Endpoint type that returns the result of calling the HTTP(S) endpoint
|
httpEndPoint.method |
String | Conditional | Method type to request to the backend server
|
httpEndPoint.stream |
Boolean | Conditional | Whether to use the Stream feature
|
httpEndPoint.url |
String | Conditional | URL path to request to the backend server
|
requiredApiKey |
String | Required | API key usage information |
requiredApiKey.required |
Boolean | Required | Whether API key is used
|
validation |
String | Required | Validity check information |
validation.type |
String | Required | Validity check scope
|
validation.headers |
List[String] | Conditional | List of required headers subject to validity checks
|
validation.queryStrings |
List[String] | Conditional | List of required query strings subject to validity checks
|
authentication |
String | Required | Authentication information |
authentication.platform |
String | Required | Set the authentication method.
|
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"
}
]
}