I am trying to add a simple item to a board:
var helper = new MondayHelper();
string json = await helper.QueryMondayApiV2(“{"query": "{boards(limit:100){id name}}"}”);
Just to confirm, are you using the MondaySDK? Or have your created your own function to perform a query/mutation?
Just by looking at the code snippet, my guess is that you have created your own function. monday has released an SDK that takes care of all the hard work for you, you simply need to add the query/mutation string and away you go.
If I do like this I get following error:
string query = @“{”“query”“: ““mutation {create_item(board_id: 628989982, group_id:"“new_group"”, item_name: "“adding works"”, column_values: "”{\"“long_text\"”: \"“Done\"”}"”) {id} }”" }";
var res = await helper.QueryMondayApiV2(query);
Hey there @ThomasSe! @mitchell.hudson, thank you so much for jumping in here, you’re literally amazing
I am not a C# developer myself by any means, but I did some digging within the forum and here is what I was able to find:
Based on the error code you are getting, it seems like you are trying to send data to a Long Text column that is not accepted by the platform. It seems to me like this could be caused by the quotation marks, as well as a lack of a “text” declare, although those could be caused by forum formatting:
I would recommend making ssure the value conforms with each column’s data structure. You can find out more about this in the documentation, as the link suggests. Here is the data structure that is provided ed within our documentation:
Long text column
To update the long text column, send a string up to 2000 characters with the key “text”.
Raw JSON - use this in your column values variables:
JSON.stringify({ “text”: “Sample text” });
JSON string - use this in the GraphiQL editor:
“{"text":"Sample text"}”
Let us know if this helps We’re keeping our fingers crossed!
Above works without the column_values section. However with I get following error:
{
“errors”: [
{
“message”: “Parse error on “long_text” (STRING) at [1, 106]”,
“locations”: [
{
“line”: 1,
“column”: 106
}
]
}
],
“account_id”: 5992539
}
Also I see different ways with queries. Some is like:
query {
boards (ids: 157244624) {
owner {id}
columns {
title
type
}
}
}
And some is like mine as JSON: {“query”: …}. When do you use one over the other?
Thank you for providing the code you are having issues with, that is a big help to put your issue into context
If I recall correctly, all of the queries sent to our API have to be sent as a JSON string and a POST request. On the try-it-yourself page, that formatting is done automatically within the tool. I’ll double-check this with the team just to be sure.
That said, from what I am able to tell, the reason you are having issues with this column_values part of creating the item is related to formatting the values you are trying to send properly as a JSON string. I’ve just tried to create a version of your mutation myself and here’s what seems to work within the try it yourself environment:
Hi Alex,
Thanks a lot appreciated. I got it working in the “Try it your self” environment. Did not know that existed nifty little tool. Now I got that working I can start converting it to c#. Thanks a lot. It is kind of strange however that column_values expects a string value and not just a json object.
I’m really glad I was able to help you here That’s awesome!
I’m sure you will end up making lots of cool integrations and API calls in C#. If I’m not asking for too much, it would be an amazing help to the community to share a few working code examples, even if they’re simple. Sometimes a reference point is all a developer needs in order to plow through their issue, so it would be an awesome way to give back.
@ThomasSe amazing, thank you so much! Feel free to take as much time as you need, it’s all about sharing coming from a good place and in positive spirit
If you end up getting more questions, I’d recommend starting a new topic at that point. I’m going to close this out for now!