Skip to main content

Next_items_page

  • September 30, 2024
  • 4 replies
  • 49 views

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 .

4 replies

denlunev
  • Participating Frequently
  • October 16, 2024

@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 } } }""
}";


  • Participating Frequently
  • October 16, 2024

My only recommendation is avoid building queries from strings.

Use GraphQL variables instead…

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


dvdsmpsn
Forum|alt.badge.img+1
  • Participating Frequently
  • October 20, 2024

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


  • Participating Frequently
  • October 22, 2024

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.