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: