how does the "body data (urlencoded form)" work in...
# replication-ask-ai
f
how does the "body data (urlencoded form)" work in the "inject into" fields in the pagination form ?
k
The "Inject into" field in the pagination form allows you to specify where the pagination parameters should be injected in the outgoing HTTP request. This could be in the request parameters, headers, or the body of the request. When you choose to inject into the body of the request with a non-JSON payload, you can use the
request_body_data
field. This field specifies how to populate the body of the request. If you provide a plain text, it will be sent as is. If you provide an object, it will be converted to a urlencoded form. Here is an example of how you can use it:
Copy code
yaml request_body_data:    "[{\"clause\": {\"type\": \"timestamp\", \"operator\": 10, \"parameters\":\n    [{\"value\": {{ stream_interval['start_time'] | int * 1000 }} }]\n  }, \"orderBy\": 1, \"columnName\": \"Timestamp\"}]/\n"
In this example, the
stream_interval['start_time']
variable is used to populate the value of the timestamp parameter in the request body. The
int * 1000
operation is a jinja expression that converts the timestamp to milliseconds. You can use other available variables like
next_page_token
,
stream_partition
,
stream_slice
, and
stream_state
to populate the request body based on your needs. For more details, you can refer to the [HttpRequester object documentation](https://docs.airbyte.com/connector-development/config-based/understanding-the-yaml-file/reference).
f
what if I want to populate the body of the variables parameter in the request body? can you give me an example of what should be in the inject into field?
e
@kapa.ai what if I want to populate the body of the variables parameter in the request body? can you give me an example of what should be in the inject into field?
k
In Airbyte, you can populate the body of the variables parameter in the request body using the generic parameter section at the bottom of the stream configuration form. You can freely configure query parameters, headers, and properties of the JSON body using jinja expressions and available variables. For example, if you want to inject an API key into the request, you can use the
ApiKeyAuthenticator
object. The
api_token
property is the API key to inject in the request. You can fill it in the user inputs. Here's an example:
Copy code
json "{{ config['api_key'] }}"
The
inject_into
field is used to configure how the API Key will be sent in requests to the source API. Either
inject_into
or
header
has to be defined. Here are some examples:
Copy code
json {   "inject_into": "header",   "field_name": "Authorization" }
Copy code
json {   "inject_into": "request_parameter",   "field_name": "authKey" }
In the first example, the API key is injected into the header of the HTTP request with the field name "Authorization". In the second example, the API key is injected as a request parameter with the field name "authKey". For more details, you can refer to the [YAML Reference](https://docs.airbyte.com/connector-development/config-based/understanding-the-yaml-file/reference) in the Airbyte documentation.