1

I revealed that tutorial schema version ref from tutorial doesn't work in kafka version3.

In additional the same result I received if I try to send the same tutorial via kafka-rest v2 from cp-kafka-rest:6.2.1 instead of cp-kafka-rest:6.1.0

An assumption which I derived that schema-registry doesn't depend on kafka-rest version - is it correct?

Tutorial:

https://docs.confluent.io/platform/current/tutorials/examples/clients/docs/rest-proxy.html#basic-producer-and-consumer https://docs.confluent.io/platform/current/kafka-rest/api.html#post--clusters-cluster_id-topics-topic_name-records

The message:

{
  "key": {
    "subject_name_strategy": "TOPIC_NAME",
    "schema_id": 8,
    "data": 1000
  },
  "value": {
    "data": {
      "countInfo": {
        "count": 0
      }
    }
  }
}

The answer:

"Error when fetching schema version. subject = test-key, schema = [{\"type\":\"record\",\"name\":\"countInfo\",\"fields\":[{\"name\":\"count\",\"type\":\"long\"}]}]"
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Irina
  • 939
  • 1
  • 8
  • 26
  • 1
    The versions do matter because the REST Proxy includes a versioned Registry HTTP client, and the internal models changed around versions 5.x-6.x – OneCricketeer Nov 04 '21 at 18:28

1 Answers1

0

with version 7.1.0, it work

key schema :

{"type": "string"}

value schema:

{
    "type":"record",
    "name":"countInfo",
    "fields":[
        {
            "name":"count",
            "type":"long"
        }
    ]
}
import requests

data = {
    "key": {
        "data": "AAAAAA"
    },
    "value": {
        "data": {"count": 4546}
    }
}
print(data)
response = requests.post(
    f"{rest_proxy}/v3/clusters/toto/topics/tata/records",
    headers={"Content-Type": "application/json"},
    json=data)
print(response.reason)
print(response.text)


give

{'key': {'data': 'AAAAAA'}, 'value': {'data': {'count': 4546}}}
OK
{"cluster_id":"toto","topic_name":"tata","partition_id":1,"offset":32,"timestamp":"2022-06-19T23:22:05.481Z","key":{"type":"AVRO","subject":"tata-key","schema_id":1,"schema_version":1,"size":12},"value":{"type":"AVRO","subject":"tata-value","schema_id":2,"schema_version":1,"size":7}}
raphaelauv
  • 670
  • 1
  • 11
  • 22