Seasoned developer, but complete newbie to both monday.com and graphql, so please forgive me for what is probably a dumb question. Also, this is probably more a graphql question than monday, but I’ve searched around, and none of the graphql code snippets that I’ve found work, so asking here in the hope that someone can help me.
I want to be able to get hold of all the items in a board. I found some code that does part of the job…
SyntaxEditor Code Snippet
{“query”: “{ boards(ids: [00000000]) { items_page(limit: 100) { cursor items { id name column_values { id text value column { id type title settings_str } } } } } }”}
This returns 100 items in JSON format, which I can parse.
However, I’m stuck trying to order the results, and trying to get the rest of the data. The results of the above query start like this…
{
boards(ids: ["00000000"]) {
items_page(
limit: 100,
query_params: {
order_by: [{
column_id: "name",
direction: desc # or asc
}]
}
) {
cursor
items {
id
name
column_values {
id
text
value
column {
id
type
title
settings_str
}
}
}
}
}
}
{"errors":[{"message":"Invalid GraphQL request","extensions":{"details":"failed to deserialize the request body into JSON: expected `,` or `}` at line 1 column 29","code":"INVALID_GRAPHQL_REQUEST"}}],"account_id":123456789}
Also, do you know how I would get the next 100 items and so on?
Well, all I’m doing is sending the exact same query (with the new lines removed as that seems to choke the API), which works fine with other queries.
I’m using C#, and the following code works fine for all other queries…
HttpClient client = new();
using (HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://api.monday.com/v2")) {
request.Content = new StringContent(<JSON>.Replace(Environment.NewLine, " "), Encoding.UTF8, "application/json");
request.Headers.Add("Authorization", <TOKEN>);
using (HttpResponseMessage response = await client.SendAsync(request)) {
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
}
Any idea why this would be?
However, getting the items in order is nice, but not essential. My main issue is with getting the subsequent pages. If you could show me how to do that I’d be very grateful.