List<String> property in JSON config in REST

Hi

could you help me with next question:
i am trying to add new connector using REST API

i am using MyConnector extends AbstractSpoolDirSourceConnector
and MyConnectorConfig extends AbstractSpoolDirSourceConnectorConfig

as i understand all properties from “config” field of JSON should be moved into private final Map<String, Object> values field under my MyConnectorConfig
and there is public List getList(String key) method available

i tried to add list property in my json config but in this case REST API returns error:

“Cannot deserialize instance of java.lang.String out of START_ARRAY token\n at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 1400] (through reference chain: org.apache.kafka.connect.runtime.rest.entities.CreateConnectorRequest[“config”]->java.util.LinkedHashMap[“myProperty”])”

my question is: why in one hand (in AbstractConfig) we have Map<String, Object> values
and in other hand (in CreateConnectorRequest) we have Map<String, String> config that prevents us to use anything but String as values
is it possible to pass List through it or I have to do additional conversion in/from String?

P.S. for number and boolean it is working fine: REST is not returning error and values can be taken from config using getInt() and getBoolean() methods

1 Like

looks like List should be defined in JSON in next format

“myProperty”: “value-1, value-2”

in this case I can use myConnectorConfig.getList(“myProperty”) and get it as java.util.Arrays$ArrayList

[value-1, value-2]

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.