1

I am building a small service using Google Cloud Endpoints

class MyMsg(messages.Message):
  f1 = messages.StringField(1, required=True)

@endpoints.api(...)
class MyService(remote.Service):

  @endpoints.Method(MyMsg, MyMsg):
  def test(self, request):
    return request

When I make an HTTP call to this rest service without sending necessary parameters, I get the following error message:

{
 "error": {
  "code": 400,
  "errors": [
   {
    "domain": "global",
    "message": "Error parsing ProtoRPC request (Unable to parse request content: Message MyMsg is missing required field f1)",
    "reason": "badRequest"
   }
  ],
  "message": "Error parsing ProtoRPC request (Unable to parse request content: Message MyMsg is missing required field f1)"
 }
}

Is there a way to customize this error message? I want to know if I can have something like below in the error response.

[
  {
    "field_name": "<>",
    "error": "<>"
  },
]
4

0 回答 0