I am building an api that is hosted on App Engine Standard (Python).
I have test it with curl and I was able to make a successfully post request:
curl --header "Content-Type: application/json" \
--request POST \
--data '{"amount":xxxx,"currency":"xxx","date":xxxx,"name":"xxxx","symbol":"xxx"}' \
https://xxxxxxxxxx.appspot.com/api/add/
Then I deployed an Api Gateway to access my App Engine Standard back end.
Getting started with API Gateway and App Engine
I tested and it worked fine for GET requests.
Now I am having issue performing a POST request. This is my code from config.yaml
file:
/add:
post:
summary: Creates a new transaction.
operationId: create-transaction
consumes:
- application/json
parameters:
- in: body
name: transaction
description: The transaction to create.
schema:
type: object
required:
- name
symbol
currency
amount
date
properties:
name:
type: string
symbol:
type: string
currency:
type: string
amount:
type: number
date:
type: integer
x-google-backend:
address: https://xxxxxxx.appspot.com
path_translation: [ APPEND_PATH_TO_ADDRESS ]
jwt_audience: 272804158038-6kc250fms52o33b7dcfjrl1f9d8rripb.apps.googleusercontent.com
responses:
'201':
description: A successful transaction created
schema:
type: string
When I am trying to run the same curl command :
curl --header "Content-Type: application/json"
--request POST
--data '{"amount":xxxx,"currency":"xxx","date":xxxx,"name":"xxxx","symbol":"xxxx"}'
https://saxxx-xxxxxxx-gateway.dev/add/
I receive :
{"message":"no healthy upstream","code":503}
Can somebody please help me troubleshooting this error message ? Again, I am able to run successfully GET requests on the same Gateway.
This is the log I found on Logging :
{
httpRequest: {
latency: "0s"
protocol: "http"
remoteIp: ""
requestMethod: "POST"
requestSize: "936"
requestUrl: "/add"
responseSize: "158"
status: 503
}
insertId: ""
jsonPayload: {
api_key_state: "NOT CHECKED"
api_method: "1.xxxxxx_2ere0etrrw81sxxxxxxxxxxxxxx_cloud_goog.Createtransaction"
api_name: "1.xxxxxxxxxxx_api_2exxxxxx_cloud_goog"
api_version: "1.0.0"
location: ""
log_message: "1.sxxxxxxxxxxx.Createtransaction is called"
producer_project_id: "xxxxxx"
response_code_detail: "no_healthy_upstream"
service_agent: "ESPv2/2.21.0"
service_config_id: "sxxxxxxxx4jvuvmlcb"
timestamp: 1616270864.269634
}
logName: "projects/sagexxxxxxxx.apigateway.xxxxxxxxx.cloud.goog%2Fendpoints_log"
receiveTimestamp: "2021-03-20T20:07:46.372838475Z"
resource: {
labels: {
location: ""
method: "1.xxxxxxxxxxxx_goog.Createtransaction"
project_id: ""
service: "xxxxxxxxxxxxx.cloud.goog"
version: "1.0.0"
}
type: "api"
}
severity: "ERROR"
timestamp: "2021-03-20T20:07:44.269633934Z"
}
I had a problem with my config.yaml
file code:
/add:
post:
summary: Creates a new transaction.
operationId: create-transaction
consumes:
- application/json
produces:
- application/json
parameters:
- in: body
name: body
required: false
schema:
$ref: '#/definitions/Model0'
x-google-backend:
address: https://appspot.com
path_translation: [ APPEND_PATH_TO_ADDRESS ]
jwt_audience: .googleusercontent.com
responses:
'201':
description: A successful transaction created
schema:
type: string
definitions:
Model0:
properties:
amount:
type: number
format: double
currency:
type: string
date:
type: integer
format: int64
name:
type: string
symbol:
type: string