Skip to main content

Hi i Am trying to to call next_items_page in C# with graph API below string

string queryNextQuery = “{ "query": "” + @“{ next_items_page(cursor: “”” + cursorObj + “", limit: 2) { cursor items { id name } } }” + “" }”;


Its working in Monday API play ground but when we call from C# application its throw error

HTTP/1.1 500 Internal Server Error

Date: Fri, 30 Sept 2024 16:46:42 GMT

Content-Type: text/html

Transfer-Encoding: chunked

Connection: keep-alive

x-request-id: 1b0d73bf-b731-99b8-b1a0-0308cc78235e

x-runtime: 8.957594

x-envoy-upstream-service-time:…


Please Provide us Solution what we are missing .

@knpashish since it’s working via the playground, then the problem is within C# code. It looks like it’s related to formatting strings GraphQL query in C#.


Try this:


string queryNextQuery = @"{
""query"": ""{ next_items_page(cursor: \\"" " + cursorObj + @"\\"", limit: 2) { cursor items { id name } } }""
}";


My only recommendation is avoid building queries from strings.


Use GraphQL variables instead…


This way you don’t have to worry about escaping anything.


💯 what @anon29275264 says here. Pass values in through variables and it’s much less error prone.


I’ve been recommending that the documentation examples be changed to use variables and eliminate the inline injection of values into the string for a couple years because those without serious graphql experience will go off the examples and find themselves in the nightmare of string escaping all over.


Reply