how to use an property defined as array into a req...
# replication-ask-ai
m
how to use an property defined as array into a request parameter as string values separated by comma?
k
The knowledge sources don't provide a direct, fully documented solution for joining an array config property into a comma-separated string for use in a request parameter. However, based on the available information, here are the approaches you can consider: Option 1: Use stream_slices (Python CDK custom connector) Instead of passing the whole array as a single parameter, iterate over each value using
stream_slices
. This makes one API request per value:
Copy code
class SoStream(HttpStream, ABC):

    def __init__(self, config: Mapping[str, Any], **kwargs):
        super().__init__()
        self.form_ids = config['form_id']  # now an array

    def stream_slices(self, **kwargs):
        for form_id in self.form_ids:
            yield {"form_id": form_id}

    def path(self, stream_slice: Mapping[str, Any] = None, **kwargs) -> str:
        return stream_slice["form_id"]
And update your
spec.yaml
to accept an array:
Copy code
form_id:
  type: array
  title: Form ID
  description: Unique identifier for one of your forms
  order: 3
[stream slices forum; passing array spec] Option 2: Use ListPartitionRouter (Declarative/YAML connector) If you're using the config-based connector framework, you can use a
ListPartitionRouter
to iterate over values from a config array:
Copy code
partition_router:
  type: ListPartitionRouter
  values: "{{ config['form_ids'] }}"
  cursor_field: "form_id"
  request_option:
    type: RequestOption
    field_name: "form_id"
    inject_into: "request_parameter"
[partition router docs] Option 3: Join array into a comma-separated string (custom injection) If the API accepts a single comma-separated parameter, you can use Jinja expressions in the connector builder's generic parameter section. However, the knowledge sources do not explicitly show a built-in Jinja filter for joining arrays into a comma-separated string in this context. The custom parameter injection feature allows flexible expressions, but the exact syntax for joining an array from config is not demonstrated in the available sources. [custom injection docs] For the Python CDK, you could handle this manually in `request_params`:
Copy code
def request_params(self, stream_state, stream_slice=None, next_page_token=None):
    return {"form_ids": ",".join(self.form_ids)}
> Note: The knowledge sources do not explicitly document a declarative YAML approach for joining an array into a comma-separated string. If you need that specific behavior in the low-code builder, it may not be fully supported at this time. 👍 0 button 👎 0 button â„šī¸ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.