httpcurlgraphqlmonday.com

Creating an Item in a Board using an Http request/cURL


Hi I have this cURL request that I have been trying and failing to get it right, it gives me a 500 Error (Internal Error)

Please see my curl request below:

curl --location --request POST "https://api.monday.com/v2" --header "Authorization: XXXXX" --header "Content-Type: application/json" --data-raw "{\"query\":\"mutation { create_item (board_id: 1622487816,group_id: \"emailed_items\", item_name: \"Test from Curl\") { id } }\"}" -v

I get back an empty object as a response but on the response header I see a 500 error message

enter image description here


Solution

  • Make sure your quotes are nested and escaped properly.

    Your code:

    "{\"query\":\"mutation { create_item (board_id: 1622487816,group_id: \"emailed_items\", item_name: \"Test from Curl\") { id } }\"}"
    

    You are right to begin with a double quote and you are right to escape the first set of quotes within those quotes.

    However, when you get further in the query, "emailed_items" also needs to be escaped, but since you are already in a set of quotes, you actually need three backslashes.

    Corrected code:

    "{\"query\":\"mutation { create_item (board_id: 1622487816,group_id: \\\"emailed_items\\\", item_name: \\\"Test from Curl\\\") { id } }\"}"