When I am trying to create a kafka connector with the name which is already in use through rest call, I got a error saying,
{"error_code":409,"message":"Connector Test already exists"}
I want to bypass this error , for example while creating kafka Topic we have something like below,
./kafka-topics **--if-not-exists**  --create --zookeeper localhost:2181 --replication-factor  1 --partitions 1  --topic test
Do we have something like --if-not-exists  while creating kafka connectors?
The way I like to do it us to use the PUT method to the config endpoint, like this:
curl -i -X PUT -H "Accept:application/json" -H  "Content-Type:application/json" \
http://localhost:8083/connectors/my-connector-name/config -d "@my-connector-config.json"
The behavior is to create in case it doesn't exist and update otherwise, more in the documentation here: https://docs.confluent.io/current/connect/references/restapi.html#put--connectors-(string-name)-config
Note that your json payload doesn't need to contain name and config, but only the config contents as in the docs example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With