Query for null or not null | Community
Skip to main content
Answered

Query for null or not null

  • June 15, 2023
  • 1 reply
  • 350 views

url = "https://api.intercom.io/conversations/search"

headers = {

'Accept': 'application/json',

'Authorization': 'Bearer auth-token',

"Intercom-Version": "2.9",

"Content-Type": "application/json"

}

params = {

  "query": { "operator": "AND", "value": [ { "field": "team_assignee_id", "operator": "!=", "value": None}]}

}

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

 

I want to get all assigned conversation and I have only one conversation and it’s team_assignee_id value is null. This query should return an empty list, but it is returning that conversation. What is the correct setup to get only assigned conversations? Also, for whatever reason, the equal(“=”) operator returns the same result. 

"query": {"field": "team_assignee_id","operator": "=","value": None}
This query using equals and not equals return an empty list.

Best answer by Ted Martinez

I figured it out. You gotta use an empty string instead of None. This returns all the assigned conversations. 
"query": { "operator": "AND", "value": [ { "field": "team_assignee_id", "operator": "!=", "value": ''}]}

1 reply

  • Author
  • New Participant
  • Answer
  • June 15, 2023

I figured it out. You gotta use an empty string instead of None. This returns all the assigned conversations. 
"query": { "operator": "AND", "value": [ { "field": "team_assignee_id", "operator": "!=", "value": ''}]}