http:身体场路径' foo'必须是不重复的信息。'

时间:2017-12-16 15:04:36

标签: google-cloud-endpoints grpc

我尝试使用gcloud端点上的gRPC helloworld示例设置将HTTP / JSON转码为gRPC。我对helloworld.proto文件的注释是:

service Greeter {
  // Sends a greeting
  rpc SayHello (HelloRequest) returns (HelloReply) {
    option (google.api.http) = {
      post: "/v1/hello"
      body: "name"
    };
  }
}

我的服务配置是:

http:
  rules:

  - selector: helloworld.Greeter.SayHello
    post: /v1/hello
    body: name

生成api_descriptor.pb文件后,执行:

gcloud endpoints services deploy api_descriptor.pb api_config.yaml

我得到了:

ERROR: (gcloud.endpoints.services.deploy) INVALID_ARGUMENT: Cannot convert to service config. 
'ERROR: helloworld/helloworld.proto:43:3: http: body field path 'foo' must be a non-repeated message.'

非常感谢任何帮助。 :)

1 个答案:

答案 0 :(得分:1)

显然,身体不能是基础类型。在消息中包装名称似乎有效:

service Greeter {
  // Sends a greeting
  rpc SayHello (HelloRequest) returns (HelloReply) {
    option (google.api.http) = {
      post: "/v1/hello"
      body: "person"
    };
  }
}

message Person {
  string name = 1;
}

// The request message containing the user's name.
message HelloRequest {
  Person person = 1;
}