arunicbe
(Arun)
September 23, 2024, 2:38pm
1
I have a Clients board with Mobile (phone column). I use API to search the board and get the matching client id.
Please see the Clients board with values in the attached screenshot.
I use this query for search.
query { boards (ids: 1917599964) {
items_page (query_params: {rules: [{column_id: “mobile”, compare_value: [“+912222333345”]}]}) {
cursor
items {
id
name
}
}
}
}
I get this result even thourh there is row in the board with matching mobile number value.
{“data”:{“boards”:[{“items_page”:{“cursor”:null,“items”: }}]},“account_id”:25600960}
Need help to fix this.
Hi @arunicbe ,
Welcome to the community!
You’re missing the operator
argument in your query (see more here ). Since you’re filtering by the phone number as a string, you would use contains_text
.
I added the operator and removed the + sign from the phone number string, and it successfully returned the items for me.
Here’s the updated query:
query { boards (ids: 1917599964) {
items_page (query_params: {rules: [{column_id: "mobile", compare_value: ["912222333345"], operator:contains_text}]}) {
cursor
items {
id
name
}
}
}
}
Let us know if you have other questions!
Best,
Rachel
arunicbe
(Arun)
September 24, 2024, 3:15am
3
I just copied the query in my code. Now it is giving just null as result.
arunicbe
(Arun)
September 24, 2024, 12:34pm
4
I am using PHP to call the api. My full code is below:
<?php
$token = 'xxx';
$apiUrl = 'https://api.monday.com/v2';
$headers = ['Content-Type: application/json', 'Authorization: ' . $token];
$query = 'query { boards (ids: 1917599964) { ' .
' items_page (query_params: {rules: [{column_id: "mobile", compare_value: ["912222333345"], operator:contains_text}]}) { ' .
' cursor ' .
' items { ' .
' id ' .
' name ' .
' } ' .
' } ' .
' } ' .
' } ' ;
$data = @file_get_contents($apiUrl, false, stream_context_create([
'http' => [
'method' => 'POST',
'header' => $headers,
'content' => json_encode(['query' => $query]),
]
]));
$responseContent = json_decode($data, true);
echo json_encode($responseContent);
?>
Upon investigation, I found PHP showing warning like this.
Warning: file_get_contents(https://api.monday.com/v2 ): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
However, another api call I have is working fine.
Hello there @arunicbe ,
Our logs appear to indicate that the column you are trying to use (of ID “mobile”) is not being found.
You can check the IDs of your board with a query like this one:
{
boards(ids: 1234567890) {
columns {
id
title
}
}
}
Also, I recommend using something like this instead of your query:
{
items_page_by_column_values(
limit: 50
board_id: 1234567890
columns: [{column_id: "phone__1", column_values: ["9720531111111"]}]
) {
cursor
items {
id
name
}
}
}
I hope that helps!
Cheers,
Matias
arunicbe
(Arun)
September 25, 2024, 4:54pm
6
Arun:
912222333345
Both working. Thanks for your help.
Happy to help @arunicbe !!!