Skip to content

Update webhook definitions via: contentful space import #2705

@marcogrcr

Description

@marcogrcr

I would like to be able to update webhooks using the contentful space import command. Currently, the command only capable of creating webhooks, but fails when attempting to update them.

Expected Behavior

The import of a webhook with an existing id results in a successful update.

Actual Behavior

The import fails with the following error:

{
  "ts": "(redacted)",
  "level": "error",
  "error": {
    "name": "Conflict",
    "entity": {
      // (redacted)
    },
    "data": {
      "status": 409,
      "statusText": "Conflict",
      "message": "Please pass sys.version as HTTP header \"X-Contentful-Version\".",
      "details": {},
      "request": {
        "url": "/spaces/(redacted)/webhook_definitions/(redacted)",
        "headers": {
          "Accept": "application/json, text/plain, */*",
          "Content-Type": "application/vnd.contentful.management.v1+json",
          "X-Contentful-User-Agent": "app contentful.cli/3.3.3; feature space-import; sdk contentful-management.js/11.31.1; platform node.js/v20.11.0; os macOS/v20.11.0;",
          "CF-Sequence": "(redacted)",
          "Authorization": "Bearer (redacted)",
          "User-Agent": "axios/1.7.3",
          "Content-Length": "310",
          "Accept-Encoding": "gzip, compress, deflate, br"
        },
        "method": "put",
        "payloadData": "(redacted)"
      },
      "requestId": "(redacted)"
    }
  }
}

Possible Solution

Based on a superficial analysis, it should be enough to populate the webhooks field of AllDestinationData in getDestinationData(), since it's currently set to an empty array.

Steps to Reproduce

  1. Create a webhook in a space.
  2. Export the webhook definition of that space using the contentful space export command.
  3. Change the name of the webhook in the exported file.
  4. Import the webhook in the same space using the contentful space import command.

Context

I want to maintain my webhooks using an infrastructure as code approach. The contentful space import command seemed like a perfect fit. However, due to this limitation I was forced to implement a custom solution. I would like to not have to maintain a custom solution and instead be able to utilize the official CLI.

Environment

See the X-Contentful-User-Agent HTTP header in the Actual Behavior section.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions