Forums/Community/Zendesk API

Answered

API v2: Manipulating ticket tags

Gary Cao
asked this on May 12, 2012 17:59

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.

 

Comments

User photo
Gary Cao

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.

May 12, 2012 18:03
User photo
Steven Yan
Product Manager

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.

May 16, 2012 00:48
User photo
Geoff Clare
opengroup

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.

August 24, 2012 09:39
User photo
Ryan Olson

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.

September 07, 2012 10:23
User photo
Paul
onapp

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?

November 06, 2012 04:52
User photo
DeVaris Brown
Zendesk

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. 

November 16, 2012 14:35
User photo
DeVaris Brown
Zendesk
Check Answer

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.
November 29, 2012 20:44
User photo
Ryan Olson

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

January 23, 2013 11:42
User photo
Stephen Honor

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?

January 23, 2013 13:47
User photo
DeVaris Brown
Zendesk

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

January 23, 2013 17:29
User photo
DeVaris Brown
Zendesk

@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.

January 23, 2013 17:40
User photo
Brandon Grantham

 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

 

March 25, 2013 15:41
User photo
Brandon K.
Zendesk

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

March 29, 2013 16:43
User photo
Gorka
doctorsim

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

August 05, 2013 08:55
User photo
Samuel Trachtenberg
digitalpublishing

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!!

 

January 27, 2014 02:37