Hello. I am trying to create REST API connector th...
# ask-ai
r
Hello. I am trying to create REST API connector throu terraform. On UI it works like a charm but when trying to create throu terraform i am getting :
unknown status code returned: Status 422 {"status":422,"type":"<https://reference.airbyte.com/reference/errors#unprocessable-entity>","title":"unprocessable-entity","detail":"The body of the request was notunderstood","documentationUrl":null,"data":null}
This is my config.What i am missing ? :
Copy code
resource "airbyte_source_custom" "json_placeholder" {
  name         = "Custom JSONPlaceholder Source"
  workspace_id = var.airbyte_workspace_id  # Your Airbyte workspace ID
  configuration = jsonencode({
    url = "<https://jsonplaceholder.typicode.com>",  
    http_method = "GET", 
    path = "/posts",  
    headers = {
      "User-Agent" = "python-requests/2.32.3",  # Example header
      "Accept"     = "*/*"                      # Example header
    },
    body = jsonencode({}),  # No body for GET requests
    primary_key = ["id"],  
    pagination_type = "None"
  })
}
u
Based on the error message you're receiving, it seems like the API is unable to process the request body you're sending. The error message indicates that the request body does not fulfill the specification. Here are a few things you could check: 1. Configuration Format: Ensure that the configuration you're passing to the
airbyte_source_custom
resource is correctly formatted. The
jsonencode
function should correctly format your configuration, but you might want to double-check the values you're passing in. 2. Required Fields: Make sure all required fields are included in your configuration. The error message might be due to a missing or incorrectly formatted field. 3. Data Types: Ensure that all fields are of the correct data type. For example, the
primary_key
field should be an array of strings, and the
headers
field should be an object. 4. API Compatibility: Check if the Airbyte version you're using supports creating custom connectors via the Terraform provider. You can refer to the [Airbyte API documentation](https://reference.airbyte.com/reference/start) or the [Terraform provider documentation](https://reference.airbyte.com/reference/using-the-terraform-provider) for more details. If you're still encountering issues, it might be helpful to compare your Terraform configuration with the configuration you used in the UI. There might be subtle differences that are causing the API request to fail. Here's an example of how to create a custom connector using the Terraform provider from the [Airbyte documentation](https://github.com/airbytehq/airbyte/issues/32744):
Copy code
hcl resource "airbyte_source_custom" "custom" {   name = "custom source connector"   workspace_id = var.workspace_id   definition_id = "d96b3d38-a35c-4f68-902d-212f4b214ed2"   configuration = "{\"configuration_1\": \"setting_1\"}" }
Please note that this is just an example and you'll need to replace the
name
,
workspace_id
,
definition_id
, and
configuration
values with your own.
r
@kapa.ai i want to have a new connection. how to get definition_id ?
u
There are several ways to get the
definition_id
for a new connection in Airbyte: 1. From the Airbyte UI: You can get the
definition_id
by navigating to the details of the source or destination in the Airbyte UI. The
definition_id
is part of the URL. 2. From the Airbyte API: If you're using the Airbyte API, you can get the
definition_id
from the response content when you create a source or destination. 3. From the Airbyte Database: You can also run a SQL query on the Airbyte database to get the
definition_id
. For example, you can run the following query to get the
definition_id
for a specific connector builder project:
Copy code
sql     SELECT actor_definition_id AS definition_id     FROM connector_builder_project     WHERE id = 'your-project-id';
Or you can run the following query to get the
definition_id
for a specific source or destination:
Copy code
sql     select * from actor_definition where actor_definition.docker_repository like '%<image-name>';
4. From the Octavia CLI: If you're using the Octavia CLI, you can run the
octavia list connectors sources
command to get the
definition_id
for a specific source. Please replace the placeholders (
'your-project-id'
,
'%<image-name>'
, etc.) with your actual values. Sources: - [Github Issue (closed): [Roadmap] Custom Connectors available through Airbyte API & Terraform Provider](https://github.com/airbytehq/airbyte/issues/32744) - [Tutorials > Version control Airbyte configurations with Octavia CLI](https://airbyte.com/tutorials/version-control-airbyte-configurations) - [Unable to find custom connector using Terraform > Official answer](https://github.com/airbytehq/airbyte/discussions/40699) - [Documentation > Operator-guides > Configuring Connector Resources > Configuring Connector-Specific Requirements](https://docs.airbyte.com/operator-guides/configuring-connector-resources#configuring-connector-specific-requirements) - [Tutorials > Create and Monitor a Data Pipeline Using the Airbyte API](https://airbyte.com/tutorials/create-and-monitor-a-data-pipeline-using-the-airbyte-api)
r
@kapa.ai i used From the Airbyte UI From the Airbyte but the code still can not find this resource
u
A message from kapa.ai
u
If you're encountering a
resource-not-found
error, it could be due to a few reasons: 1. Incorrect UUID: Ensure that the
definition_id
you're using is correct. It should be the UUID from the URL of the source or destination details page in the Airbyte UI. 2. Custom Connector: If you're using a custom connector, you might need to manually retrieve the
sourceDefinitionId
. You can do this by going to
Sources > New source > Custom tab
and then clicking on your custom connector. The
sourceDefinitionId
is the UUID at the end of that page's URL. 3. API Issues: If you're using the Airbyte API, make sure that the API endpoint and request body are correct. A
400 Bad Request
error could indicate that the API request is malformed or the
definition_id
does not exist. 4. Deployment Issues: If you're deploying a connection between two workspaces (e.g.,
dev
>
prod
), you might need to manually copy the custom source YAML manifest from the
dev
workspace to the
prod
workspace. Then, in the
prod
workspace, go to
Sources > New source > Custom tab
to get the
sourceDefinitionId
and fill this in the Terraform source definition. If you're still encountering issues, consider reaching out to the Airbyte community on [Slack](https://slack.airbyte.com/) or the [Airbyte Forum](https://github.com/airbytehq/airbyte/discussions) for further assistance. Sources: - [Github Issue (closed): [Roadmap] Custom Connectors available through Airbyte API & Terraform Provider](https://github.com/airbytehq/airbyte/issues/32744) - [Unable to find custom connector using Terraform](https://github.com/airbytehq/airbyte/discussions/40699)