My spring boot project has a numerous number of rest APIs and to deploy using Cloud Endpoint, it throws error. Application runs in GKE.
Error shows Method does not exists. I have referred the issue and I am not using default root path for checking the status in openapi.yaml
Here is configuration:
openapi.yaml
# [START swagger]
swagger: "2.0"
info:
description: "SPR API"
title: "SPR API"
version: "1.0.0"
host: "spr-api.endpoints.spr-mza-dev.cloud.goog"
# [END swagger]
schemes:
- "http"
paths:
"/statuscheck":
get:
description: "Returns Status code"
operationId: "status"
parameters:
- name: name
in: query
description: "Status verification"
required: true
type: string
#produces:
#- "application/json"
responses:
200:
description: "Status 200"
Deployment.yaml
apiVersion: v1
kind: Service
metadata:
name: spr-api
spec:
ports:
- port: 80
targetPort: 8081
protocol: TCP
name: http
selector:
app: spr-api
type: LoadBalancer
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: spr-api
spec:
replicas: 1
template:
metadata:
labels:
app: spr-api
spec:
containers:
# [START esp]
- name: esp
image: gcr.io/endpoints-release/endpoints-runtime:1
args: [
"--http_port", "8081",
"--backend", "127.0.0.1:8080",
"--service", "spr-api.endpoints.spr-mza-dev.cloud.goog",
"--rollout_strategy", "managed",
]
# [END esp]
ports:
- containerPort: 8081
- name: spr-api
image: "gcr.io/spr-mza-dev/sprapis:latest"
ports:
- containerPort: 8080
Whiling hitting endpoint I get bellow error:
{
code: 5,
message: "Method does not exist.",
details: [
{
@type: "type.googleapis.com/google.rpc.DebugInfo",
stackEntries: [ ],
detail: "service_control"
}
]
}
Thanks for your valuable inputs.
Regards.
What is your URL when getting 404?
Could you also provide parsed service config? You can get it by CLI
gcloud endpoints configs describe
It could be a missmatch between your openapi.yaml that was used to configured your API into endpoints and your actual spring-boot API code.
In my case I faced that same issue and the cause was that in my swagger file (OpenAPI) I missed a basePath configuration! My API code running inside GKE was expecting requests starting with the path /api/v1
but this was not mapped into my endpoints configuration (swagger.yaml).
Check if the path displayed at Method columns into your endpoints console is the same is configured inside you application running into GKE. In my Method console was displaying only /elements
not the full path /api/v1/elements
and then after updating my OpenAPI configuration adding the BasePath it was solved.
References: