I’m having an issue attempting to create a schema for a single topic, customer
, that can have multiple event types. I’m using Avro for SerDes and Confluent Cloud Schema Registry.
I am using the following command:
curl -u <KEY>:<SECRET> -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" --data @customerTypes.json <CONFLUENT_CLOUD_URL>/subjects/customer-value/versions
When I execute this command, I get the following error:
{"error_code":42201,"message":"Invalid schema [ \"com.example.customer\", \"com.example.product\" ] with refs [{name='com.example.customer', subject='customer-created-value', version=1}, {name='com.example.product', subject='product-created-value', version=1}] of type AVRO"}%
Here is my customerTypes.json
:
{
"schema": "[ \"com.example.customer\", \"com.example.product\" ]",
"references": [
{
"name": "com.example.customer",
"subject": "customer-created-value",
"version": 1
},
{
"name": "com.example.product",
"subject": "product-created-value",
"version": 1
}
]
}
I have also attempted to provide the JSON as part of the command (before extracting to a file, depicted above), which yields the same error code, 42201 - Invalid Schema
:
{"error_code":42201,"message":"Invalid schema [ { \"name\": \"com.example.customer\", \"subject\": \"customer-created-value\", \"version\": 1 }, { \"name\": \"com.example.product\", \"subject\": \"product-created-value\", \"version\": 1 }] with refs [{name='com.example.customer', subject='customer-created-value', version=1}, {name='com.example.product', subject='product-created-value', version=1}] of type AVRO"}%
Side note, I have read this article, this article, and the docs, as well as, multiple forum posts including this post and I’m still confused on how I can create a schema for a single topic to have multiple event types? What am I missing?
Additionally, since there is a limitation on the ability to view and edit schemas through the Control Center UI (only works with TopicNameStrategy
, but I would need to use RecordNameStrategy
or TopicRecordNameStrategy
, which is why I’m resorting to CLI), I am under the assumption this feat can only be accomplished through my current plan of attack, via command line or can this be accomplished through the Control Center?
This is just an arbitrary example, as I am just trying to understand how I can even do this with just a simple example, as I’m obviously doing something wrong. Therefore, if anyone can provide an example of how I can get this to work (or can provide a different example), that would be greatly appreciated!