Search code examples
gitlabgitlab-api

GitLab: how to get the label added date by GitLab API


I'm using GitLab 15.3.1 version and I'd like to obtain, using GitLab API, the label added date for a project issue.

This information is available from GitLab web browser interface as shown below

enter image description here

Is there any way to obtain that "11/10/2022 2.44pm" via API for that issue?

Thank you in advance


Solution

  • You can get Label events for a single Issue with the List project issue label events API.

    Here's an example using this Issue:

    curl --header 'Authorization: Bearer xxxTOKENxxx' https://gitlab.com/api/v4/projects/278964/issues/378378/resource_label_events | jq '.'
    

    Response:

    [
      {
        "id": 192875035,
        "user": {
          "id": 9671578,
          "username": "rzwambag",
          "name": "Roy Zwambag",
          "state": "active",
          "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/9671578/avatar.png",
          "web_url": "https://gitlab.com/rzwambag"
        },
        "created_at": "2022-10-19T08:51:15.420Z",
        "resource_type": "Issue",
        "resource_id": 117155410,
        "label": {
          "id": 17963221,
          "name": "application performance::active",
          "description": " Any issues that group::application performance has scheduled and is working on. They are in the build phase of the product development flow.",
          "description_html": " Any issues that group::application performance has scheduled and is working on. They are in the build phase of the product development flow.",
          "text_color": "#FFFFFF",
          "color": "#69D100"
        },
        "action": "add"
      },
      {
        "id": 192875036,
        "user": {
          "id": 9671578,
          "username": "rzwambag",
          "name": "Roy Zwambag",
          "state": "active",
          "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/9671578/avatar.png",
          "web_url": "https://gitlab.com/rzwambag"
        },
        "created_at": "2022-10-19T08:51:15.420Z",
        "resource_type": "Issue",
        "resource_id": 117155410,
        "label": {
          "id": 10690783,
          "name": "group::application performance",
          "description": "Issues belonging to the Application Performance group (formerly known as Memory) of the Enablement stage of the DevOps lifecycle. See https://about.gitlab.com/handbook/product/categories/#application-performance-group",
          "description_html": "Issues belonging to the Application Performance group (formerly known as Memory) of the Enablement stage of the DevOps lifecycle. See <a href=\"https://about.gitlab.com/handbook/product/categories/#application-performance-group\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">https://about.gitlab.com/handbook/product/categories/#application-performance-group</a>",
          "text_color": "#333333",
          "color": "#A8D695"
        },
        "action": "add"
      },
      {
        "id": 192875037,
        "user": {
          "id": 9671578,
          "username": "rzwambag",
          "name": "Roy Zwambag",
          "state": "active",
          "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/9671578/avatar.png",
          "web_url": "https://gitlab.com/rzwambag"
        },
        "created_at": "2022-10-19T08:51:15.420Z",
        "resource_type": "Issue",
        "resource_id": 117155410,
        "label": {
          "id": 15119514,
          "name": "type::maintenance",
          "description": "Upkeeping efforts and catch-up corrective improvements that are not Feature nor Bugs. Read more at https://about.gitlab.com/handbook/engineering/metrics/#work-type-classification",
          "description_html": "Upkeeping efforts and catch-up corrective improvements that are not Feature nor Bugs. Read more at <a href=\"https://about.gitlab.com/handbook/engineering/metrics/#work-type-classification\" rel=\"nofollow noreferrer noopener\" target=\"_blank\">https://about.gitlab.com/handbook/engineering/metrics/#work-type-classification</a>",
          "text_color": "#FFFFFF",
          "color": "#330066"
        },
        "action": "add"
      },
      {
        "id": 192875043,
        "user": {
          "id": 1786152,
          "username": "gitlab-bot",
          "name": "🤖 GitLab Bot 🤖",
          "state": "active",
          "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/1786152/avatar.png",
          "web_url": "https://gitlab.com/gitlab-bot"
        },
        "created_at": "2022-10-19T08:51:16.579Z",
        "resource_type": "Issue",
        "resource_id": 117155410,
        "label": {
          "id": 25316145,
          "name": "devops::data_stores",
          "description": "Issues for the Systems stage of the DevOps lifecycle (Memory, Database, Global Search, Sharding)",
          "description_html": "Issues for the Systems stage of the DevOps lifecycle (Memory, Database, Global Search, Sharding)",
          "text_color": "#FFFFFF",
          "color": "#E44D2A"
        },
        "action": "add"
      },
      {
        "id": 192875044,
        "user": {
          "id": 1786152,
          "username": "gitlab-bot",
          "name": "🤖 GitLab Bot 🤖",
          "state": "active",
          "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/1786152/avatar.png",
          "web_url": "https://gitlab.com/gitlab-bot"
        },
        "created_at": "2022-10-19T08:51:16.579Z",
        "resource_type": "Issue",
        "resource_id": 117155410,
        "label": {
          "id": 14918396,
          "name": "section::enablement",
          "description": "Issues related to the Enablement section",
          "description_html": "Issues related to the Enablement section",
          "text_color": "#FFFFFF",
          "color": "#F0AD4E"
        },
        "action": "add"
      },
      {
        "id": 192875250,
        "user": {
          "id": 9671578,
          "username": "rzwambag",
          "name": "Roy Zwambag",
          "state": "active",
          "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/9671578/avatar.png",
          "web_url": "https://gitlab.com/rzwambag"
        },
        "created_at": "2022-10-19T08:52:13.714Z",
        "resource_type": "Issue",
        "resource_id": 117155410,
        "label": {
          "id": 2526320,
          "name": "workflow::in dev",
          "description": "Issues that are actively being worked on by a developer",
          "description_html": "Issues that are actively being worked on by a developer",
          "text_color": "#FFFFFF",
          "color": "#428BCA"
        },
        "action": "add"
      },
      {
        "id": 192875320,
        "user": {
          "id": 9671578,
          "username": "rzwambag",
          "name": "Roy Zwambag",
          "state": "active",
          "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/9671578/avatar.png",
          "web_url": "https://gitlab.com/rzwambag"
        },
        "created_at": "2022-10-19T08:52:28.908Z",
        "resource_type": "Issue",
        "resource_id": 117155410,
        "label": {
          "id": 2526320,
          "name": "workflow::in dev",
          "description": "Issues that are actively being worked on by a developer",
          "description_html": "Issues that are actively being worked on by a developer",
          "text_color": "#FFFFFF",
          "color": "#428BCA"
        },
        "action": "remove"
      }
    ]