Eugene Goldberg
Eugene Goldberg

Reputation: 15564

how to properly register Protobuf schema with Schema Registry / Kafka-Rest

I am trying to post a Protobuf schema to the Schema Registry using kafka-rest interface:

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"

I am getting this error:

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

Question: what is the proper way to indicate the media type for this to work?

Upvotes: 5

Views: 1174

Answers (1)

feroze
feroze

Reputation: 7594

You need to send it in a JSON envelope, since it is not an avro schema.

$ 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; }\"}"

Upvotes: 1

Related Questions