# JSON Payload with Schema Validation on Kafka REST Proxy

**URL:** <https://forum.confluent.io/t/json-payload-with-schema-validation-on-kafka-rest-proxy/7380>\
**Category:** Schema Registry\
**Created:** [9 March 2023 05:17 UTC](https://forum.confluent.io/t/json-payload-with-schema-validation-on-kafka-rest-proxy/7380 "2023-03-09T05:17:59Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![KKumar](https://avatars.discourse-cdn.com/v4/letter/k/f17d59/32.png) [@KKumar](https://forum.confluent.io/u/KKumar)\
**Post date:** [9 March 2023 05:17 UTC](https://forum.confluent.io/t/json-payload-with-schema-validation-on-kafka-rest-proxy/7380/1 "2023-03-09T05:17:59Z")

</div>

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

```auto
{
    "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,

```auto
{
    "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
}

```

---

<div class="post-metadata">

**Author:** ![christophelannoyadeo](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/christophelannoyadeo/32/3039_2.png) [@christophelannoyadeo](https://forum.confluent.io/u/christophelannoyadeo)\
**Post date:** [14 June 2023 14:45 UTC](https://forum.confluent.io/t/json-payload-with-schema-validation-on-kafka-rest-proxy/7380/2 "2023-06-14T14:45:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sheikhi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/sheikhi/32/2914_2.png) [@sheikhi](https://forum.confluent.io/u/sheikhi)\
**Post date:** [21 August 2023 15:44 UTC](https://forum.confluent.io/t/json-payload-with-schema-validation-on-kafka-rest-proxy/7380/3 "2023-08-21T15:44:14Z")

</div>

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”  
}  
}

---

<div class="post-metadata">

**Author:** ![shabbirpanjesha](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@shabbirpanjesha](https://forum.confluent.io/u/shabbirpanjesha)\
**Post date:** [15 May 2024 06:03 UTC](https://forum.confluent.io/t/json-payload-with-schema-validation-on-kafka-rest-proxy/7380/4 "2024-05-15T06:03:51Z")

</div>

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#](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”  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![sheikhi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/sheikhi/32/2914_2.png) [@sheikhi](https://forum.confluent.io/u/sheikhi)\
**Post date:** [5 September 2024 13:38 UTC](https://forum.confluent.io/t/json-payload-with-schema-validation-on-kafka-rest-proxy/7380/5 "2024-09-05T13:38:15Z")

</div>

> [@shabbirpanjesha](#):
>
> Record DefaultRecord(offset=0, timestamp=1715752932349, key=7 bytes, value=50 bytes) is rejected by the record interceptor

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.

---

<div class="post-metadata">

**Author:** ![Sahithi\_2002](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@Sahithi\_2002](https://forum.confluent.io/u/Sahithi_2002)\
**Post date:** [1 April 2025 09:55 UTC](https://forum.confluent.io/t/json-payload-with-schema-validation-on-kafka-rest-proxy/7380/6 "2025-04-01T09:55:17Z")

</div>

iam using REST v3 endpoint and in my topic i have enabled schema validation, but unable to produce message to the topic getting this error  
Record DefaultRecord(offset=0, timestamp=1715752932349, key=7 bytes, value=50 bytes) is rejected by the record interceptor.  
i have one question does REST V# enpoint support schema validation.

---

<div class="post-metadata">

**Author:** ![sheikhi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/sheikhi/32/2914_2.png) [@sheikhi](https://forum.confluent.io/u/sheikhi)\
**Post date:** [1 April 2025 13:13 UTC](https://forum.confluent.io/t/json-payload-with-schema-validation-on-kafka-rest-proxy/7380/7 "2025-04-01T13:13:55Z")

</div>

> [@Sahithi\_2002](#):
>
> endpoint and in my topic i have enabled schema validation, but unable to produce message to the topic getting this error  
> Record DefaultRecord(offset=0, timestamp=1715752932349, key=7 bytes, value=50 bytes) is rejected by the record interceptor.  
> i have one question does REST V# endpoint support schema validation.

Yes, it supports schema validation. If “type” is specified it validates the schema.

---

<div class="post-metadata">

**Author:** ![Sahithi\_2002](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@Sahithi\_2002](https://forum.confluent.io/u/Sahithi_2002)\
**Post date:** [1 April 2025 13:37 UTC](https://forum.confluent.io/t/json-payload-with-schema-validation-on-kafka-rest-proxy/7380/8 "2025-04-01T13:37:38Z")

</div>

i am using this uri [https://xyz/kafka/v3/clusters/xyz/topics/grocery-anonymous-sessions/records](https://xyz/kafka/v3/clusters/xyz/topics/grocery-anonymous-sessions/records) and trying to produce messages  
with this payload  
‘{“value”:{“type”:“JSON”,“data”:{“session\_id”: “123”,“interaction\_time”: “123”}}}’  
but iam facing this error  
{“error\_code”:50002,“message”:“Record DefaultRecord(offset=0, timestamp=1743514376471, key=0 bytes, value=45 bytes) is rejected by the record interceptor io.confluent.cloud.kafka.schemaregistry.validator.CloudRecordSchemaValidator”}

---

<div class="post-metadata">

**Author:** ![Sahithi\_2002](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@Sahithi\_2002](https://forum.confluent.io/u/Sahithi_2002)\
**Post date:** [1 April 2025 13:42 UTC](https://forum.confluent.io/t/json-payload-with-schema-validation-on-kafka-rest-proxy/7380/9 "2025-04-01T13:42:52Z")

</div>

[https://xyz:443/kafka/v3/clusters/Xyz/topics/grocery-anonymous-sessions/records](https://xyz:443/kafka/v3/clusters/Xyz/topics/grocery-anonymous-sessions/records) -d ‘{“value”:{“data”:{“session\_id”: “123”,“interaction\_time”: “123”}}}’  
{“error\_code”:422,“message”:“Error: 42206 : Payload error. Schema Registry must be configured when using schemas.”}

if iam using like this then iam getting this error , i have just enabled in topic config to validate schema for value and added a data contract and trying to hit this uri to produce message . Is there any more config needed to do this

---

<div class="post-metadata">

**Author:** ![sheikhi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/sheikhi/32/2914_2.png) [@sheikhi](https://forum.confluent.io/u/sheikhi)\
**Post date:** [1 April 2025 14:33 UTC](https://forum.confluent.io/t/json-payload-with-schema-validation-on-kafka-rest-proxy/7380/11 "2025-04-01T14:33:05Z")

</div>

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”  
}  
}

---

<div class="post-metadata">

**Author:** ![Sahithi\_2002](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@Sahithi\_2002](https://forum.confluent.io/u/Sahithi_2002)\
**Post date:** [1 April 2025 14:38 UTC](https://forum.confluent.io/t/json-payload-with-schema-validation-on-kafka-rest-proxy/7380/12 "2025-04-01T14:38:23Z")

</div>

the uri iam using is correct or worng ? and can guide me a little how to use v3 rest proxy to produce a message with schema validation enabled with avro serialization?  
Even With type specified it is not
