Skip to main content

Failed to insert record to Monday.com via api v2

  • August 12, 2020
  • 25 replies
  • 5126 views

  • Participating Frequently

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

This topic has been closed for replies.

25 replies

dsilva
Forum|alt.badge.img
  • Participating Frequently
  • August 12, 2020

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


  • Participating Frequently
  • August 12, 2020

I would also check if you have given sufficient permission(s) for your feature.


  • Author
  • Participating Frequently
  • August 14, 2020

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}}}


  • Author
  • Participating Frequently
  • August 14, 2020

the code worked before, then suddenly stopped working.


pepperaddict
  • Participating Frequently
  • August 14, 2020

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\\"}

  • New Participant
  • September 15, 2020

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\\"}


pepperaddict
  • Participating Frequently
  • September 15, 2020

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.


  • New Participant
  • September 16, 2020

Thank you. Let me try.


AlexSavchuk
Forum|alt.badge.img
  • monday.com Team Member
  • September 16, 2020

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.

@HLin

Please let us know if you need any further assistance, we’d love to make sure this is working for you.

-Alex


  • New Participant
  • September 21, 2020

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 }” }"


  • New Participant
  • September 23, 2020

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 }” }"


pepperaddict
  • Participating Frequently
  • September 28, 2020

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.


dsilva
Forum|alt.badge.img
  • Participating Frequently
  • September 28, 2020

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.


  • Author
  • Participating Frequently
  • October 12, 2020

I’m attaching a screenshot of the code. Maybe that’s better to see.


  • Author
  • Participating Frequently
  • October 12, 2020

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.


pepperaddict
  • Participating Frequently
  • October 13, 2020

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?


dsilva
Forum|alt.badge.img
  • Participating Frequently
  • October 14, 2020

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


  • Author
  • Participating Frequently
  • October 20, 2020

Sorry for the late reply. We use php. Are there any demo programs with apiv2 in php?


  • Author
  • Participating Frequently
  • October 20, 2020

Sorry for the late reply. We use php. Are there any demo programs with apiv2 in php?


dsilva
Forum|alt.badge.img
  • Participating Frequently
  • October 21, 2020

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


  • Author
  • Participating Frequently
  • October 26, 2020

Thank you very much.


  • Author
  • Participating Frequently
  • October 28, 2020

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.


dsilva
Forum|alt.badge.img
  • Participating Frequently
  • October 28, 2020

Glad to hear @Hilary! Let us know if you have any other questions 🙂

-Daniel


  • Author
  • Participating Frequently
  • October 30, 2020

So far, it’s good. It’s working well. Thanks.


  • February 25, 2021

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.