With stripe api, you can pass in param like "--dat...
# ask-ai
y
With stripe api, you can pass in param like "--data-urlencode "expand[]=items.data.discounts"*;".* Since the built-in stripe connector doesn't expand that discount object, *h*ow do yo specify that in a custom connector yaml file?
k
To specify the expansion of nested fields like items.data.discounts in a custom connector YAML file for Stripe, you need to configure the query parameters to include the expand[] parameter with the appropriate value. In Airbyte's Connector Builder, you can add custom query parameters in the stream configuration. For nested expansions, you would set a query parameter with the key expand[] and the value items.data.discounts. This mimics the way you would use --data-urlencode "expand[]=items.data.discounts" with curl. Here’s how you can do it in the YAML:
Copy code
yaml streams:   - name: your_stream_name     ...     request_parameters:       expand[]: items.data.discounts
Or, if you are using the Connector Builder UI, you would add a query parameter with: - Key: expand[] - Value: items.data.discounts This approach is supported by Airbyte’s generic parameter injection, which allows you to freely configure query parameters, including those required for field expansion in APIs like Stripe. You can use this method to expand any nested object supported by the Stripe API, as long as you specify the correct path in the expand[] parameter. If you need to inject more complex or dynamic values, you can use Jinja expressions in the value field, but for static expansions like this, a plain string is sufficient. For more details, see the documentation on custom parameter injection in the Connector Builder UI: [Custom parameter injection](https://docs.airbyte.com/platform/connector-development/connector-builder-ui/pagination#custom-parameter-injection). Note: The knowledge sources do not provide a full YAML example specifically for Stripe expansions, but the general method for adding custom query parameters is documented and applicable here. If you encounter issues with the built-in Stripe connector not expanding certain fields, this custom connector approach allows you to control the expansion directly in your configuration<sup>[Custom parameter injection](https://docs.airbyte.com/platform/connector-development/connector-builder-ui/pagination#custom-parameter-injection)</sup>.
y
@kapa.ai I get this error: Received an unsuccessful response from the API. Check the Response tab for the full API response. Check the Request tab to verify the expected request was sent.
Copy code
[]
Connector logs 2 ERROR
Copy code
Bad request. Please check your request parameters. - Traceback (most recent call last):
  File "/home/airbyte/.pyenv/versions/3.10.14/lib/python3.10/site-packages/airbyte_cdk/sources/abstract_source.py", line 133, in read
    yield from self._read_stream(
  File "/home/airbyte/.pyenv/versions/3.10.14/lib/python3.10/site-packages/airbyte_cdk/sources/abstract_source.py", line 239, in _read_stream
    for record_data_or_message in record_iterator:
  File "/home/airbyte/.pyenv/versions/3.10.14/lib/python3.10/site-packages/airbyte_cdk/sources/streams/core.py", line 192, in read
    for record_data_or_message in records:
  File "/home/airbyte/.pyenv/versions/3.10.14/lib/python3.10/site-packages/airbyte_cdk/sources/declarative/declarative_stream.py", line 136, in read_records
    yield from self.retriever.read_records(self.get_json_schema(), stream_slice)
  File "/home/airbyte/.pyenv/versions/3.10.14/lib/python3.10/site-packages/airbyte_cdk/sources/declarative/retrievers/simple_retriever.py", line 378, in read_records
    for stream_data in self._read_pages(record_generator, self.state, _slice):
  File "/home/airbyte/.pyenv/versions/3.10.14/lib/python3.10/site-packages/airbyte_cdk/sources/declarative/retrievers/simple_retriever.py", line 301, in _read_pages
    response = self._fetch_next_page(stream_state, stream_slice, next_page_token)
  File "/home/airbyte/.pyenv/versions/3.10.14/lib/python3.10/site-packages/airbyte_cdk/sources/declarative/retrievers/simple_retriever.py", line 487, in _fetch_next_page
    return self.requester.send_request(
  File "/home/airbyte/.pyenv/versions/3.10.14/lib/python3.10/site-packages/airbyte_cdk/sources/declarative/requesters/http_requester.py", line 305, in send_request
    request, response = self._http_client.send_request(
  File "/home/airbyte/.pyenv/versions/3.10.14/lib/python3.10/site-packages/airbyte_cdk/sources/streams/http/http_client.py", line 392, in send_request
    response: requests.Response = self._send_with_retry(
  File "/home/airbyte/.pyenv/versions/3.10.14/lib/python3.10/site-packages/airbyte_cdk/sources/streams/http/http_client.py", line 236, in _send_with_retry
    response = backoff_handler(rate_limit_backoff_handler(user_backoff_handler))(request, request_kwargs, log_formatter=log_formatter, exit_on_rate_limit=exit_on_rate_limit)  # type: ignore # mypy can't infer that backoff_handler wraps _send
  File "/home/airbyte/.pyenv/versions/3.10.14/lib/python3.10/site-packages/backoff/_sync.py", line 105, in retry
    ret = target(*args, **kwargs)
  File "/home/airbyte/.pyenv/versions/3.10.14/lib/python3.10/site-packages/backoff/_sync.py", line 105, in retry
    ret = target(*args, **kwargs)
  File "/home/airbyte/.pyenv/versions/3.10.14/lib/python3.10/site-packages/backoff/_sync.py", line 105, in retry
    ret = target(*args, **kwargs)
  File "/home/airbyte/.pyenv/versions/3.10.14/lib/python3.10/site-packages/airbyte_cdk/sources/streams/http/http_client.py", line 310, in _send
    raise MessageRepresentationAirbyteTracedErrors(
airbyte_cdk.sources.streams.http.http_client.MessageRepresentationAirbyteTracedErrors: Bad request. Please check your request parameters.
ERROR
Copy code
None - Traceback (most recent call last):
  File "/home/airbyte/.pyenv/versions/3.10.14/lib/python3.10/site-packages/airbyte_cdk/connector_builder/message_grouper.py", line 302, in _read_stream
    yield from AirbyteEntrypoint(source).read(source.spec(self.logger), config, configured_catalog, state)
  File "/home/airbyte/.pyenv/versions/3.10.14/lib/python3.10/site-packages/airbyte_cdk/entrypoint.py", line 189, in read
    for message in self.source.read(self.logger, config, catalog, state):
  File "/home/airbyte/.pyenv/versions/3.10.14/lib/python3.10/site-packages/airbyte_cdk/sources/declarative/manifest_declarative_source.py", line 165, in read
    yield from super().read(logger, config, catalog, state)
  File "/home/airbyte/.pyenv/versions/3.10.14/lib/python3.10/site-packages/airbyte_cdk/sources/abstract_source.py", line 177, in read
    raise AirbyteTracedException(message=error_message, failure_type=FailureType.config_error)
airbyte_cdk.utils.traced_exception.AirbyteTracedException: None
Without this, the connector can pull data successfully
Copy code
request_parameters:
      expand[]: items.data.discounts
k
A message from kapa.ai
Based on the knowledge sources provided, there is no explicit documentation or example showing how to use the expand[] parameter for nested fields like items.data.discounts in a custom connector YAML file for Stripe. The official Airbyte documentation on configuring request parameters in the YAML file describes how to set key-value pairs for query parameters, but does not address the use of array-style parameters (like expand[]) or their behavior with nested fields in Stripe specifically [Understanding the YAML file: Requester](https://docs.airbyte.com/platform/connector-development/config-based/understanding-the-yaml-file/requester). Your error message indicates that including:
Copy code
yaml request_parameters:   expand[]: items.data.discounts
results in a "Bad request" error from the Stripe API, while omitting it allows the connector to pull data successfully. This suggests that either the parameter is not being sent in the correct format, or the Stripe API does not accept this particular expansion in the context of your request. From the knowledge sources, there is no mention of special handling or encoding for array-style query parameters (like expand[]) in Airbyte's declarative YAML connectors. There is also no Stripe-specific guidance or workaround documented for this scenario. Summary: I'm sorry, but the knowledge sources do not contain enough information to confirm the correct way to specify expand[] for nested fields in a custom connector YAML file for Stripe, nor do they explain why this would cause a "Bad request" error. You may need to consult Stripe's API documentation for the correct usage of expand[] or seek further support from the Airbyte community or Stripe support for this specific use case.
y
@kapa.ai You said this is the correct format, but in the request url, "[]" is not passed through. Maybe that's the issue?
Copy code
request_parameters:
  expand[]: items.data.discounts
Request url: expand%5B%5D=items.data.discounts
k
A message from kapa.ai
You're correct to notice that Airbyte encodes the parameter as
expand%5B%5D=items.data.discounts
in the request URL, which is the standard URL encoding for
expand[]=items.data.discounts
. This is how most HTTP clients encode array-style query parameters, and Stripe's API documentation shows examples using this format (i.e.,
expand[]=...
). However, based on your experience and the error, it appears that either: - Stripe is not accepting this particular expansion in the context of your request, or - There may be a limitation or bug in how Airbyte handles this parameter in the declarative YAML connector. The knowledge sources do not provide explicit guidance or troubleshooting steps for this specific scenario—there is no documentation confirming whether Airbyte's declarative connectors support array-style query parameters like
expand[]
for Stripe, nor do they mention any required workarounds or known issues with this approach. Summary: The encoding
expand%5B%5D=items.data.discounts
is technically correct for
expand[]=items.data.discounts
, and this is how such parameters are expected to be sent. If Stripe is rejecting the request, it may be due to the context of the expansion or a limitation in the connector, but the knowledge sources do not provide enough information to confirm the root cause or a solution. You may need to consult Stripe's API documentation for allowed expansions or seek further support from the Airbyte community for this specific use case. If you have success pulling data without the expand parameter, it suggests the issue is with the expansion itself, not the encoding format.
y
@kapa.ai It gives me error 400, so I think the issue might be the format, I don't know. Can you escape these characters in airbuyte...?
k
A message from kapa.ai
I'm sorry, but the knowledge sources do not contain explicit information about escaping characters in query parameter keys (such as using
expand[]
vs.
expand%5B%5D
) within Airbyte's declarative YAML or Connector Builder. The documentation and examples only show how to add custom query parameters using key-value pairs, and do not address escaping or alternative encoding for array-style parameters like
expand[]
in Stripe requests [Custom parameter injection](https://docs.airbyte.com/platform/connector-development/connector-builder-ui/pagination#custom-parameter-injection). From your description and the standard behavior of HTTP clients, Airbyte's encoding of
expand[]
as
expand%5B%5D
is correct and should be accepted by Stripe, as this matches Stripe's documented usage. If you are still receiving a 400 error, the issue is likely not with the encoding/escaping of the brackets, but possibly with the value being passed, the context of the request, or a limitation in the connector. In summary: There is no information in the knowledge sources about escaping or altering the encoding of these characters in Airbyte. The format Airbyte uses is standard, and if you are getting a 400 error, the root cause is likely elsewhere. If you need further troubleshooting, you may need to consult Stripe's API documentation or seek help from the Airbyte community.