Curl example of a mutation with variables

I was successful using the “try it” feature of the api docs to perform a mutation using variables. Now I’m trying to convert that syntax into a curl command. Even when putting data in a file (then referencing with @filename) in the curl command, the amount of escaping and quoting is driving me bonkers. All I ever get is a “400 Bad Request” in the headers, nothing to indicate what’s invalid. I’ve seen some sample updates with curl, but none with variables.

Can someone post a working example please?
Thanks!

Sorry, more specifically what I’m looking for is a mutation create_item with column_values (using variables). I can actually get a new item created, but the column_values are never set.

Hey @lmatter!

I just played around with this, and you can use the following cURL command to populate an item with values from a variable. However, there is still a lot of escaping involved, since the column values need to be passed as a JSON string. Are you solely using cURL to call the API?

curl -X POST -H "Content-Type:application/json" -H "Authorization:xxxxx" 'https://api.monday.com/v2' \
-d '{"query" : "mutation($name:String!, $columns:JSON!){create_item(item_name:$name, board_id:162169280, column_values:$columns){name}}", "variables" : "{\"name\" : \"This is a var\", \"columns\" : \"{\\\"status\\\" : {\\\"index\\\" : 4}}\"}"}'

Thanks! Actually, I just switched over to Postman, but I still need help getting my create-item to populate the column_values. I’ll take a look at your example to see if it gets me further. If you have a postman example that would be awesome!

I replied to this thread as I’m now using postman:

I am having a similar issue, trying to create an item on a board and setting a person to be assigned to it. The item gets created but the name of the person never gets filled.

This is my QL:
mutation {

create_item (board_id: 248361481, group_id: “oa_generated”, item_name: “Test5”,column_values:"{[{“id”:8203162,“kind”:“person”}]}") {
id
}
}

what am i missing

Hey @djpsantos! :wave:

For the column values, you’ll need to pass a JSON object that uses column IDs for the keys and the values that you want to set for the values themselves. Something like this:

"column_values" : {"text1" : "This is text", "status1" : {"label" : "Done"}}

As for the person column, I’d suggest using the format described in our documentation here.

Let me know if that helps!

Cheers,
Dipro