Not all metadata (Zendesk ticket) in task seems to be available through API

I’m using the following Python function to get a specific task object.

def get_task_info(task_id):
    return client.tasks.get_task(task_gid=task_id)

In the returned object I’m able to access different custom fields that we have created. I’m also able to change the values of these custom fields through the API. No errors are appearing from any of my calls currently.

However, we have the Zendesk integration which allows you to link a ticket via the GUI. You paste the specific ticket link and then a small widget populates with some of the ticket data.

This Zendesk ticket information is nowhere in the returned task through the API. How do I look up the ticket link or manually assign it when that field does not appear in what’s returned through the function?

Thanks for any help on this.

If the Zendesk integration is using the latest AppComponent feature (currently in Beta) then information is attached to the task through an attachment. If you query attachment on a task, you’ll probably see something related to ZenDesk. It does not give you access to data about the ticket though, as this data is coming from Asana calling their specific widget endpoint…

My guess: you can’t get that data unless reading the Zendesk API.

@Phil_Seeman @iliaZelenkin @lpb any idea?

2 Likes

Thanks for the feedback @Bastien_Siebman. I guess I’m not clear on how the attachments work with the task. When I look at the task JSON there is no reference to attachments even though I can see it in the GUI as a comment.

There’s also no reference to attachments (except for search filters) in the documentation related to the task. How am I supposed to get an attachment for the task if there’s no visibility in the metadata that there even is an attachment?

Can you try calling this endpoint with the task gid as parent?

Here’s the function I’m attempting now:

def get_zendesk_ticket_attachment(gid):
    print(client.attachments.get_attachments_for_object({'parent':gid}))

And here is the output I’m seeing:

>>> customer_success.get_zendesk_ticket_attachment("1202613114519965")
<generator object PageIterator.items at 0x7fd73021b0b0>

Okay I iterated through the returned object and there was some metadata there:

{'gid': '1202623230894952', 'name': 'Archiving Failure - EVENT#ec62e27b-9c3a-5009-a169-fdcee031b5bb', 'resource_type': 'attachment', 'resource_subtype': 'external'}

Looks like the gid is the Asana internal ID. Then name is the ticket name from Zendesk. However I don’t see the URL or Zendesk ticket number. I guess I need to start searching on the Zendesk API side to understand how they are connecting this now.

Check out the attachment schema in the doc, and request for all missing fields. I know for a fact that there is a url field I don’t see here.

2 Likes

That looks to have done the trick! When you query the task for attachments you iterate through the results to get the specific attachment GID. Then when you query that specific GID you get all the fields.

result = client.attachments.get_attachment("1202623230894952")

{
    "gid": "1202623230894952",
    "created_at": "2022-07-19T22:35:01.778Z",
    "download_url": null,
    "host": "external",
    "name": "Archiving Failure - EVENT#ec62e27b-9c3a-5009-a169-fdcee031b5bb",
    "parent": {
        "gid": "1202613114519965",
        "name": "Test name",
        "resource_type": "task",
        "resource_subtype": "default_task"
    },
    "permanent_url": "https://app.asana.com/app/asana/-/get_asset?asset_id=1202623230894952",
    "resource_type": "attachment",
    "resource_subtype": "external",
    "view_url": "https://nuclei.zendesk.com/agent/tickets/30111111"
}
3 Likes