Need help with create_item via the api using C#

I am coding an api in C# .net. Here is a query I send to Monday.com which works just fine and retrieves the items:

{“query”: "{boards (ids: 5493163446) { items { id name state } } } "}

I have patterned create_item after that but all of these seven mutations result in a Server Error 500. This is my first create so I could use some basic help, for example, do I need to use the word query or just mutation and is the mutation in quotes or curly braces, etc. I have removed any column values to try and simply the query as much as possible - could it be complaining because there are no column values, just the name?

{“query”: "mutation: create_item (“board_id”: 5493163446, “group_id”: “new_group”, “item_name”: “This item imported programmatically”) " { id } }

{“query”: "mutation {create_item (“board_id”: 5493163446, “group_id”: “new_group”, “item_name”: “This item imported programmatically”) } " { id } }

{“query”:“mutation { create_item (board_id: 5493163446, group_id: “new_group”, item_name: “MyNewItem”, column_values: “{“state”:“active”}”) { id } }”}

{"mutation {create_item (“board_id”: 5493163446, “group_id”: “new_group”, “item_name”: “This item imported programmatically”) } " { id } }

{“mutation”: {create_item (“board_id”: “5493163446”, “group_id”: “new_group”, “item_name”: “This item imported programmatically”) } { id } }

{“mutation”: “{create_item (“board_id”: “5493163446”, “group_id”: “new_group”, “item_name”: “This item imported programmatically”) }” { id } }

mutation { create_item (board_id: 5493163446, group_id: new_group, item_name: “This item imported programmatically”) { id } }

Be grateful for any suggestions you may have - willing to try anything.

It appears you have quotes around argument names in the string, some extraneous quotes, which shouldn’t be there. Additionally, your quotes around strings are not straight quotes but the fancy MS Word/Wordpad typographers “quotes”.

GraphQL queries are strings, not JSON. GraphQL requests are a object with the structure {query: "graphqlstring"} that has been serialized to JSON.

const request = JSON.stringify({
   query: `mutation: create_item (board_id: 5493163446, group_id: "new_group", 
           item_name: "This item imported programmatically") { id }`
});
1 Like

Thanks-you very much. Those basics really helped.

I had some trouble working through the stringify aspect as C# does not have such a method. Here is what ended up working for me, where GraphQLQuery class is downloaed from the web.

query = “mutation {create_item (board_id: 5493163446, group_id: "new_group", item_name: "New Imported task3", column_values: "{\"status\": \"Working on it\" } " ) { id } }”;
json = JsonConvert.SerializeObject(new GraphQLQuery() { Query = query });

Now this forum is modifying what I pasted: in query the single double quote should be backslash doublequote and the backslash double quote should be backslash backslash backslash double quote

Correct, the forum itself is making changes to quotes, smartquotes etc. Therefore it is a good idea to always

copy / past code inside preformatted text (cntrl-e)

Thank you for the help @codyfrisch @basdebruin !!