Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tickets/search API unable to retrieve tickets with a custom ticket_attribute set #139

Open
tommyhutcheson opened this issue Mar 12, 2024 · 2 comments

Comments

@tommyhutcheson
Copy link

tommyhutcheson commented Mar 12, 2024

tickets/search API unable to retrieve tickets with a custom ticket_attribute set

Hello

I am looking to use the tickets/search API to retrieve tickets with a particular ticket_attribute set.

This might already be possible but I am getting the syntax wrong, I can see on this page https://developers.intercom.com/docs/references/rest-api/api.intercom.io/Tickets/searchTickets/
it says you can use ticket_attribute.{id} as a field key but when I try this with a ticket attribute I am getting an error - field_not_found The request ticket attribute ID is not a valid integer response 400

Please advise on what I could be doing wrong here, thank you

Expected

import requests

url = https://api.intercom.io/tickets/search
 
payload = {
  "query": {

    "operator": "AND",

    "value": [

      {

        "field": "ticket_attribute.{my_ticket_attribute}",

        "operator": "=",

        "value": "Ready"

      },

      ]

   }

}


headers = {
  "Content-Type": "application/json",

  "Intercom-Version": "2.10",

  "Authorization": "Bearer <YOUR_TOKEN_HERE>"

}


response = requests.post(url, json=payload, headers=headers)


data = response.json()

print(data)

Reproduction Steps

@DanielFrydman
Copy link

@Eclairemoy any updates on this one?

@DanielFrydman
Copy link

DanielFrydman commented Dec 13, 2024

@tommyhutcheson, I discovered how to search for specific attributes!

Instead of using "ticket_attribute.{my_ticket_attribute}",
use "ticket_attribute.123456" instead!

How to find the ID for your attribute:

  1. Fetch a ticket.
  2. Look for the ticket_type_attribute object corresponding to your attribute.
  3. You’ll receive something like this:
{
    "type": "ticket_type_attribute",
    "id": "123456",
    "workspace_id": "...",
    "name": "Your ticket attribute name",
    "description": null,
    "data_type": "string",
    "input_options": {
        "multiline": false
    },
    "order": 4,
    "required_to_create": false,
    "required_to_create_for_contacts": false,
    "visible_on_create": true,
    "visible_to_contacts": false,
    "default": false,
    "ticket_type_id": 1,
    "archived": false,
    "created_at": 1734009610,
    "updated_at": 1734009610
}
  1. Grab the id field from this object.

Example usage:

{
    "field": "ticket_attribute.123456",
    "operator": "=",
    "value": "unknown"
}

Done!

@Eclairemoy I think you can close this ticket!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants