I am trying to create a new schema
using the kafka-schema-registery
api. below is the implementation :
let value = JSON.stringify(avroSchema);
let type= {"schema" : value};
fetch(`${process.env.SCHEMA_REGISTRY_URL}/subjects/${topic}/versions`,
{
body : type,
method : 'POST',
headers :{ 'Content-Type': 'application/vnd.schemaregistry.v1+json,
application/vnd.schemaregistry+json, application/json',
'Accept' : 'application/vnd.schemaregistry.v1+json,
application/vnd.schemaregistry+json, application/json'
}
})
.then(res=>res.json())
.then((result)=>{
console.log('result is ', result);
resolve(result);
})
.catch((err)=>{
console.log('err',err);
reject(err);
})
Here is how avroSchema
looks :
const avroSchema = {
"type": "record",
"name": "test",
"fields" : [
{"name": "field", "type": "long"},
]
};
When I am executing this code I am getting 500 - Internal server error
.
Can anyone help me to understand where I am going wrong ?
For future users :
Here is how I was able to solve this :
Finally after setting the payload, make a
POST
requestoptions
as below :then make the request :