I have a requirement where I need to pull multiple data from the api. Right now what are doing we have created a custom connector as a source where I’m pulling some data which is schema less and we transform the data into JSON and dump it into the Postgres. I have a spec file which looks like this
documentationUrl: https://docs.airbyte.io/integrations/sources/surveycto
connectionSpecification:
$schema: http://json-schema.org/draft-07/schema#
title: Surveycto Spec
type: object
required:
- server_name
- username
- password
- form_id
properties:
server_name:
type: string
title: Server Name
description: The name of the SurveryCTO server
order: 0
username:
type: string
title: Username
order: 1
password:
type: string
title: Password
airbyte_secret: true
order: 2
form_id:
type: string
title: Form ID
order: 3
class SoStream(HttpStream, ABC):
primary_key = None
def __init__(self, config: Mapping[str, Any], **kwargs):
super().__init__()
self.server_name = config['server_name']
self.form_id = config['form_id']
#base64 encode username and password as auth token
user_name_password = f"{config['username']}:{config['password']}"
self.auth_token = self._base64_encode(user_name_password)
def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, Any]]:
return None
def _base64_encode(self,string:str) -> str:
return base64.b64encode(string.encode("ascii")).decode("ascii")
@property
def url_base(self) -> str:
return f"https://{self.server_name}.surveycto.com/api/v2/forms/data/wide/json/"
def request_params(
self, stream_state: Mapping[str, Any], stream_slice: Mapping[str, any] = None, next_page_token: Mapping[str, Any] = None
) -> MutableMapping[str, Any]:
return {'date': 0}
def request_headers(
self, stream_state: Mapping[str, Any], stream_slice: Mapping[str, Any] = None, next_page_token: Mapping[str, Any] = None
) -> Mapping[str, Any]:
return {'Authorization': 'Basic ' + self.auth_token }
def parse_response(
self,
response: requests.Response,
stream_state: Mapping[str, Any],
stream_slice: Mapping[str, Any] = None,
next_page_token: Mapping[str, Any] = None,
) -> Iterable[Mapping]:
response_json = response.json()
for data in response_json:
try:
yield data
except Exception as e:
msg = f"""Encountered an exception parsing schema"""
self.logger.exception(msg)
raise e
def path(
self,
stream_state: Mapping[str, Any] = None,
stream_slice: Mapping[str, Any] = None,
next_page_token: Mapping[str, Any] = None
) -> str:
return self.form_id
Right now it pulls data from the particular form_id which is string now. I need to pass multiple form_id in the spec file. Which can be an array but when I change it to an array and run the code again its giving me this error
Config validation error: ‘test_data’ is not of type ‘array’
how can I pass multiple form IDs here and what changes should I make so that I can pull data from different form_id?