GitLab API icon

GitLab API

Gitlab

Actions880

Overview

This node operation allows users to create a new snippet in GitLab by sending a POST request to the /api/v4/snippets endpoint. It is useful for automating the creation of code snippets or text snippets within GitLab projects or user accounts, facilitating code sharing and collaboration.

Use Case Examples

  1. Automatically create a snippet from a code snippet generated in another workflow.
  2. Create a snippet to store configuration or script templates in GitLab for team access.

Properties

Name Meaning
Skip Authentication Determines whether to skip authentication for the API request.
Authentication Specifies the authentication method to use, defaulting to GitLab API authentication.
baseUrl The base URL of the GitLab instance to which the API request is sent.
Method The HTTP method used for the API request, defaulting to GET but can be set to POST for this operation.
Parameter Schema Defines the schema for the parameters sent in the request body for creating a snippet.
Request Body Schema Defines the schema for the request body content when creating a snippet.
Request Path The API endpoint path for creating a snippet, fixed to /api/v4/snippets.

Output

JSON

  • id - The unique identifier of the created snippet.
  • title - The title of the snippet.
  • file_name - The file name associated with the snippet.
  • description - The description of the snippet.
  • visibility - The visibility level of the snippet (e.g., private, internal, public).
  • author
    • id - The unique identifier of the author who created the snippet.
    • name - The name of the author who created the snippet.
    • username - The username of the author who created the snippet.
  • created_at - The timestamp when the snippet was created.
  • updated_at - The timestamp when the snippet was last updated.

Dependencies

  • GitLab API authentication credential

Troubleshooting

  • Ensure the GitLab API authentication credential is correctly configured and has the necessary permissions to create snippets.
  • Verify the baseUrl is correctly set to the GitLab instance URL if using a self-hosted GitLab.
  • Check that the request body conforms to the required schema for creating a snippet, including mandatory fields like title and file_name.
  • Common error messages include authentication failures (401 Unauthorized), permission denied (403 Forbidden), and validation errors (400 Bad Request) due to missing or invalid parameters.

Links

Discussion