4

我正在尝试使用 kafka-rest 接口将 Protobuf 模式发布到模式注册表:

curl -X POST -H "Content-Type: application/vnd.kafka.protobuf.v2+json" \
   -H "Accept: application/vnd.kafka.v2+json" \
   --data '{"value_schema": "syntax=\"proto3\"; message User { string name = 1; }", "records": [{"value": {"name": "testUser"}}]}' \
   "http://localhost:8082/topics/protobuftest"

我收到此错误:

{"error_code":415,"message":"HTTP 415 Unsupported Media Type"}

问题:指示此工作的媒体类型的正确方法是什么?

4

1 回答 1

0

您需要在 JSON 信封中发送它,因为它不是 avro 模式。

$ curl -X POST -H "content-type: application/json" 
http://localhost:8081/subjects/protobuf/versions 
-d "{\"schemaType\": \"PROTOBUF\", \"schema\": \"syntax = \\\"proto3\\\";message test { int32 id = 1; }\"}"
于 2022-02-14T03:13:00.243 回答