1

API v2: Manipulating ticket tags

Hi,

First of all, great job on API v2 and documentation.

In API v2, looks like I can't use additional-tags and set-tags any more, but just directly specify the "tags" attribute containing all the tags that the ticket is supposed to have.

However, I encountered what I consider a bug.

Here's how to reproduce:

  • Create a dummy ticket

  • Get the ticket via API v2, the "tags" attribute is empty (which is correct)

  • Use API v2 to set tags to ["tag1"] like this:

ticket : {
tags : ["tag-1"]
}

The tag is correctly set, no issue so far.

  • Next, use API v2 to set tags to ["tag2"] like this:

ticket : {
tags : ["tag-2"]
}

The respond of that PUT request will show that the ticket's tags will be this:

tags : ["tag-2","tag-2]

Note the duplicate "tag-2".

Now if I GET the ticket again via the API, the tags are correctly set

tags : ["tag-2"]

So I guess there's a bug on the PUT response with duplicate tags.

Please give me some confirmation about this.

Also, is there an equivalent way to additional-tags in API v2?

Thanks.

15 comments

  • 0

    Additional information:

    When the ticket already has tags : ["tag-1", "tag-2", "tag-3"], if I do an update API call to set tags to:

    ticket : {

    tags : ["tag-4"]

    }

    The response for that PUT request would have "tags" attribute containing all 4 tags:

    tags : ["tag-1", "tag-2", "tag-3", "tag-4"]

    But when I make another GET request to get ticket details, the "tags" attribute only contain one tag: "tag-4", which I think is correct behavior. Only the PUT response is a bit confusing.

  • 0

    Thanks Gary, there's still a few gaps that we're finding in API v2, this looks like one of them.   I can definitely see the use case for adding tags without needing to know what tags already exist.  

    Thanks for reporting the bugs, I will also take this feedback back to our team and see if we can bring back the old functionality.

  • 0

    Is there any progress on these gaps in the tag handling in API v2?  I would like to be able to remove tags without needing to know what other tags exist.

  • 0

    I'm experiencing something a little different trying to remove tags from a topic (not ticket).

    I'm trying to remove some bogus tags that came in when I imported our articles from old system.

    Lots of articles have the tags "how", "to", "can", "I", etc from our old system. I'm trying to systematically remove these.

    For example

    When I GET a topic it has tags

    "tags" : ["how", "can", "I", "remove", "tags"]

    When I PUT I'm removing the ones I don't want and PUT it back as this:

    "tags" : ["remove", "tags"]

    as others have stated when the PUT request responds it comes back exactly the same

    "tags" : ["how", "can", "I", "remove", "tags"]

    When I do the next GET request nothing has changed though.

  • 0

    I'm having the same problem as Ryan, can you confirm if this is a bug in the v2 API or an issue with my json query?

  • 0

    We're addressing this issue in our current sprint. However, we won't deploy next Thursday due to the holiday. You should see this fixed 11/29. 

  • 0

    For single ticket tag updates you'll be able to pull the ticket by ID and perform the following operations:

    DELETE /api/v2/tickets/123/tags?values=[horse,cow] # Removes the two tags

    PUT /api/v2/tickets/123/tags?values=[horse,cow] # Adds the two tags

    POST /api/v2/tickets/123/tags?values=[horse,cow] # Sets the two tags

    We're working on a solution for bulk tag updates on tickets.

  • 0

    DeVaris, just out of curiosity does what you said only work for tickets or does it work with topic tags also?

  • 0

    DeVaris, I am having a bit of an issue with this, I am assuming whats listed at http://developer.zendesk.com/documentation/rest_api/tags.htm is correct but even when following the provided commands it doesn't appear to be working.

     

    I am trying to delete a tag called s_in_progress from a ticket but whatever I try, your way, the way provided in the documentation. Nothing appears to be working, even running the commands provided within the documentation.

     

    Any ideas or am I doing something completely wrong here?

  • 0

    @Stephen, can you email api@zendesk.com with the command you're trying to run so I can see what's going on?

  • 0

    @Ryan we don't have a topics endpoint that would allow you to manipulate tags like the tickets endpoint does. I'll mark that down as a feature request.

  • 0

     I’ve been trying to use the API to remove tags but no method I have found works. I tried the suggested method from the API documentation (DELETE /api/v2/tickets/{id}/tags.json) and the method with a query string that DeVaris Brown mentioned in the comment above.

    Here is my curl attempt :

     

    curl -X DELETE [https://zendeskSandbox.zendesk.com/api/v2/tickets/42/tags.json?values="tagToDelete"] --globoff -u  {xxx@yyyyy.com}:{password}

     

    And my response:

    {"tags":["tag","tagToDelete"]} 

    No tag is deleted.

    Has anyone been having issues with the delete tag functionality? 

    Thanks

     

  • 0

    Hey Brandon,

    I checked with our technical team and it looks like our documentation was wrong but was corrected yesterday. The following curl call should work:

    curl https://{subdomain}.zendesk.com/api/v2/tickets/{id}/tags.json \ 
    -X DELETE -d '{ "tags": ["customer"] }' \ 
    -H "Content-Type: application/json" -v -u {email_address}:{password}

    http://developer.zendesk.com/documentation/rest_api/tags.html

  • 0

    Hi,

    Tags update is so nice but force to make two curl cast to the Zendesk server when updating a ticket with a comment, an status updating and tag additions and removals.

    For our situation, we first read ticket tags, then made some internal changes (sometimes we need to add new tags and remove existing ones) and finally do the ticket update.

    Additional-tags, set-tags, ... behaviour was so cool to do a unique call for updating.

    Do you plan to recover that functionality?

    Thanks,

    Gorka

  • 0

    We've been bulk importing users with tags. We periodically need to update the users, which for us means replacing the old tags with new ones. It says in the documentation that when you bulk import users, the new tags on the CSV add to the pre-existing tags but do not replace them. Is there a solution so that the old tags can be replaced with the new?

    Thanks!!

     

Please sign in to leave a comment.