user25317565
user25317565

Reputation: 11

YouTrack API how to retrieve activity data regarding custom field value changes?

I'm using /api/issues/{issueID}/activities to try and view the past changes for the State field of issues on YouTrack.

I'm able to see the time changes were made and the user that made them, but when I try to access added or removed value which are supposed provide the State value that was added/removed it only returns {'$type': 'StateBundleElement'} rather than the actual value e.i. "Open", "In Progress", "Closed", etc. Anyone know what to do?

https://www.jetbrains.com/help/youtrack/devportal/resource-api-issues-issueID-activities.html#ActivityItem-supported-fields

Upvotes: 0

Views: 105

Answers (1)

Sergey Merzlov
Sergey Merzlov

Reputation: 281

You also need to provide fields you want to see for a returned entity. Here is the list of fields for StateBundleElement. For example, the request GET api/issues/DEMO-1/activities?categories=CustomFieldCategory&fields=timestamp,author(login),added(name),removed(name),category returns

[
    {
        "removed": [
            {
                "name": "Submitted",
                "$type": "StateBundleElement"
            }
        ],
        "added": [
            {
                "name": "Open",
                "$type": "StateBundleElement"
            }
        ],
        "timestamp": 1577923200000,
        "category": {
            "$type": "ActivityCategory"
        },
        "author": {
            "login": "root",
            "$type": "User"
        },
        "$type": "CustomFieldActivityItem"
    },
    {
        "removed": null,
        "added": 1592654400000,
        "timestamp": 1593356400000,
        "category": {
            "$type": "ActivityCategory"
        },
        "author": {
            "login": "Demo.User",
            "$type": "User"
        },
        "$type": "CustomFieldActivityItem"
    },
    {
        "removed": 1592654400000,
        "added": 1592740800000,
        "timestamp": 1593445767000,
        "category": {
            "$type": "ActivityCategory"
        },
        "author": {
            "login": "Demo.User",
            "$type": "User"
        },
        "$type": "CustomFieldActivityItem"
    },
    {
        "removed": 1592654400000,
        "added": null,
        "timestamp": 1593445767000,
        "category": {
            "$type": "ActivityCategory"
        },
        "author": {
            "login": "Demo.User",
            "$type": "User"
        },
        "$type": "CustomFieldActivityItem"
    },
    {
        "removed": [
            {
                "name": "Open",
                "$type": "StateBundleElement"
            }
        ],
        "added": [
            {
                "name": "In Progress",
                "$type": "StateBundleElement"
            }
        ],
        "timestamp": 1703002756610,
        "category": {
            "$type": "ActivityCategory"
        },
        "author": {
            "login": "root",
            "$type": "User"
        },
        "$type": "CustomFieldActivityItem"
    }
]

Upvotes: 0

Related Questions