we failed to insert record to Monday.com via api v2.
got eror as:
{“error_message”:“Internal server error”,“status_code”:500}
for test push record below
{
“query”: “mutation{create_item( board_id: 154534478, group_id: "video_articles", item_name: "Test - Trump to Offer Optimistic Vision in State of the Union Address", column_values: {status:{index:15},status7:{index:19},status3:{index:15},person7:{id:10603717},article4:{index:13},eet_link:{url:"https://ntd.com/trump-to-offer-optimistic-vision-in-state-of-the-union-address_284634.html\\",text:\\"https://ntd.com/trump-to-offer-optimistic-vision-in-state-of-the-union-address_284634.html\\”}}) {\\n\\t\\tid\\n\\t\\tcolumn_values {\\n\\t\\t\\tid\\n\\t\\t\\ttitle\\n\\t\\t\\tvalue\\n\\t\\t}}}"
}
Hey @Hilary - welcome!
That error usually has to do with the format of any JSON strings in your query. The first place I would check is that the right data structure is being used for each column value and if there any missing/extra commas and brackets.
For example, here is a query creating an item and populating the link:
mutation {
create_item(board_id: xxxxx, item_name: "Hello world!", column_values: "{\\"link\\" : {\\"url\\":\\"http://monday.com\\",\\"text\\":\\"go to monday!\\"}}") {
id
}
}
Would you mind posting just the query snippet you’re trying to send?
-Danny
I would also check if you have given sufficient permission(s) for your feature.
here’ the query snippet used
mutation{create_item( board_id: 154534478, group_id: "video_articles", item_name: "Test - Trump to Offer Optimistic Vision in State of the Union Address", column_values: {status:{index:15},status7:{index:19},status3:{index:15},person7:{id:10603717},article4:{index:13},eet_link:{url:":https://ntd.com/trump-to-offer-optimistic-vision-in-state-of-the-union-address_284634.html\\",text:\\"https://ntd.com/trump-to-offer-optimistic-vision-in-state-of-the-union-address_284634.html\\](https://ntd.com/trump-to-offer-optimistic-vision-in-state-of-the-union-address_284634.html\\",text:\\"https://ntd.com/trump-to-offer-optimistic-vision-in-state-of-the-union-address_284634.html\\)"}}) {\\n\\t\\tid\\n\\t\\tcolumn_values {\\n\\t\\t\\tid\\n\\t\\t\\ttitle\\n\\t\\t\\tvalue\\n\\t\\t}}}
the code worked before, then suddenly stopped working.
From what I can see, it looks like there’s markdown syntax inside link. Also, I know that each column has their own set of rules. May need to refer here: https://monday.com/developers/v2#column-values-section
For link, has it been stringified?
For example:
{\\"url\\":\\"https://www.google.com\\",\\"text\\":\\"testname\\"}
I tried to reply to this threat earlier, not sure why my post couldn’t go out. So I created another login to reply.
I didn’t quite under your reply.
Can you explain specifically what is the error and what should it be to fix bug for the example we provided?
{url:"https://ntd.com/trump-to-offer-optimistic-vision-in-state-of-the-union-address_284634.html\\",text:\\"https://ntd.com/trump-to-offer-optimistic-vision-in-state-of-the-union-address_284634.html\\"}
Hey @HLin !
I have it working this way:
const query = `mutation changeValue($value: JSON){
create_item(board_id: yourboardId , item_name: "Item Name You want", column_values: $value) {
id
}
}`
variable
The already stringified way:
const variables = {value: "{\\"link\\" : {\\"url\\":\\"https://ntd.com/trump-to-offer-optimistic-vision-in-state-of-the-union-address_284634.html\\",\\"text\\":\\"THE_TEXT_YOU_WANT_TO_SHOW\\"}}"}
or the jsonstringify way:
const value = JSON.stringify({link: {url: "THELINK", text: "THETEXT" } })
const variable = {value: value}
The column values is very strict on how it’s stringified, but it’s easier when you use JSON.stringify(). I suggest referring to here to get more information on column values: https://monday.com/developers/v2#column-values-section
Good luck. I hope that helped.
Thank you. Let me try.
Once again, our friendly neighborhood chili-fan AKA @pepperaddict does it again 🙂 Thanks so much for your friendly and clear input here, I love your contributions to the community.
Please let us know if you need any further assistance, we’d love to make sure this is working for you.
-Alex
Hi. Thanks for your help. We tested and got http code of 200, but no result in Monday record.
The string we sent:
{\\n “query”: “mutation {\\n create_item(\\n item_name: “Test - Trump to Offer Optimistic Vision in State of the Union Address”, \\n board_id: 154534478, \\n group_id: “video_articles”, \\n column_values: {“status”:{“index”:15},“status7”:{“index”:19},“status3”:{“index”:15},“person7”:{“id”:10603717},“article4”:{“index”:13},“eet_link”:{“url”:“https:\\/\\/dev1.ntd.com\\/trump-to-offer-optimistic-vision-in-state-of-the-union-address_284634.html”,“text”:“https:\\/\\/dev1.ntd.com\\/trump-to-offer-optimistic-vision-in-state-of-the-union-address_284634.html”}})\\n {\\n id\\n title\\n value\\n }\\n }” }"
We tested and got http code of 200, but no result in Monday record. Does anyone know what happened? How can we get a record on Monday.com?
The string we sent is this:
{\\n “query”: “mutation {\\n create_item(\\n item_name: “Test - Trump to Offer Optimistic Vision in State of the Union Address”, \\n board_id: 154534478, \\n group_id: “video_articles”, \\n column_values: {“status”:{“index”:15},“status7”:{“index”:19},“status3”:{“index”:15},“person7”:{“id”:10603717},“article4”:{“index”:13},“eet_link”:{“url”:“https://dev1.ntd.com/trump-to-offer-optimistic-vision-in-state-of-the-union-address_284634.html”,“text”:“https://dev1.ntd.com/trump-to-offer-optimistic-vision-in-state-of-the-union-address_284634.html”}})\\n {\\n id\\n title\\n value\\n }\\n }” }"
Hey sorry for the late reply.
Did you already manage to get it?
I see a bunch of things wrong with the code, but I can’t tell if it was changed due to you copying and pasting or your line of code is really like that. How are you sending it in? Are you using monday’s api? When pasting your code in the forum could you surround it with backticks.
One line of code you just need one backtick. If you have multiple lines of code you use 3 backticks.
I suggest testing it out in playground using your token here: monday.com
Good luck.
Hey @HLin - would you mind updating / posting your code using backticks like @pepperaddict suggested? I suspect the forum formatting may have modified the code in your original post. That way we can continue to troubleshoot this.
Hi, i’ve replied above. Sorry for the late reply. It seems I don’t get any notification when my posts gets a reply, so I didn’t see you replied a while ago.
Hey @Hilary
Thanks for the update. Hmm. Is the \\n
necessary?
How are you sending the data? Are you using Monday’s API or other? What language are you using? Could we see the whole code when it comes to sending in the request? You don’t need to take a screen shot.
You can surround it with backticks. Use three backticks for multiple lines of code.
Did you test your request in the GraphQL playground and if so, did it work?
By any chance were you able to test this code on the GraphQL playground to see if it works? I suspect this may be an issue related to the formatting on some of the column values (depending on the programming language, it might be easier to use variables as our quickstart guides use).
Could you let us know what language you are using?
-Daniel
Sorry for the late reply. We use php. Are there any demo programs with apiv2 in php?
Sorry for the late reply. We use php. Are there any demo programs with apiv2 in php?
Hey @Hilary - we have a quickstart tutorial for using PHP to make API queries.
One thing I will recommend from seeing previous users use PHP for this - I would recommend maintaining any variables within the $vars
object so that json_decode
will run on them. You can see an example of what I mean on the last example in the tutorial page:
<?php
$query = 'mutation ($myItemName: String!, $columnVals: JSON!) { create_item (board_id:YOUR_BOARD_ID, item_name:$myItemName, column_values:$columnVals) { id } }';
$vars = ['myItemName' => 'Hello world!',
'columnVals' => json_encode([
'status' => ['label' => 'Done'],
'date4' => ['date' => '1993-08-27']
])];
$data = @file_get_contents($apiUrl, false, stream_context_create([
'http' => [
'method' => 'POST',
'header' => $headers,
'content' => json_encode(['query' => $query, 'variables' => $vars]),
]
]));
$responseContent = json_decode($data, true);
echo json_encode($responseContent);
?>
-Daniel
Thank you very much.
Thank you for everyone’s help. We did some more testing again and had some success. We will continue to do the testing. Hopefully it will work well.
So far, it’s good. It’s working well. Thanks.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
Login to monday.com
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.