JSON Payload with Schema Validation on Kafka REST Proxy

I tried to achieve the scenario where JSON Payload with Schema Validation on Kafka REST Proxy should be done. I followed the below steps but getting the error, can someone please help me on this,
Step-1 – Created Topic and configured confluent.value.schema.validation = true
Step-2 – Added Avro Schema to that Topic
Step-3 – Tried to produce the below sample message to topic using rest-proxy

{
    "value_schema_id": "100032",
    "records": [
		{
			"key": "1111",
			"value": {
				"id": 11,
				"name": "Maarten",
				"faxNumber": "1234567890"
			}
		}
	]
}

But I am getting below error, can someone please help me on this,

{
    "offsets": [
        {
            "partition": null,
            "offset": null,
            "error_code": 50002,
            "error": "One or more records have been rejected due to 1 record errors in total, and only showing the first three errors at most: [RecordError(batchIndex=0, message='Record DefaultRecord(offset=0, timestamp=1678333249854, key=6 bytes, value=51 bytes) is rejected by the record interceptor io.confluent.cloud.kafka.schemaregistry.validator.CloudRecordSchemaValidator')]"
        }
    ],
    "key_schema_id": null,
    "value_schema_id": null
}

Hi, i have quite the same issue, have you found a solution ?

For me the erreor is : interceptor io.confluent.cloud.kafka.schemaregistry.validator.CloudRecordSchemaValidator

I also encounter this issue with v3 rest proxy endpoint.

The solution was adding a “type” property for the value and key payload.

{
“value”: {
“type”:“JSON”,
“data”: {
“name”: “Name”,
“age”: 10,
“salary”: 19,
“time”:“August 21 2023”
}
},
“key”:{
“type”:“JSON”,
“data”:“YOUR KEY”
}
}

1 Like

I am getting same exception. I have java code base and JSON schema configured. Appreciate if anyone could help me on this.

org.apache.kafka.common.InvalidRecordException: Record DefaultRecord(offset=0, timestamp=1715752932349, key=7 bytes, value=50 bytes) is rejected by the record interceptor io.confluent.cloud.kafka.schemaregistry.validator.CloudRecordSchemaValidator

My JSON Schema
{
“$schema”:“http://json-schema.org/draft-04/schema#”,
“title”:“Employee”,
“type”:“object”,
“additionalProperties”:false,
“javaType”:“com.example.model.Employee”,
“properties”:{
“firstName”:{
“type”:“string”
},
“lastName”:{
“type”:“string”
}
}
}

  1. Grant read access to kafka account (Which broker is using to connect to other components) to access schema subject.
  2. Make sure you are using schema aware client, so it adds the 5 magic bytes to your json payload while producing message.
  3. Broker side schema validation should be set to true - set validate value schema to true for that topic.

Post your java code (schema aware client) so we can have a look and suggest changes if needed.