cURL showing error "Not Authorized/Not Authenticated"

Hi.
I am new here. I tried to use the CURL example of modifying a column in my board.
I copied the V2 API Token from my Admin Profile and pasted in the authorization tag.

My Code:

curl -X POST -H “Content-Type:application/json” -H “Authorization:XXXXXXX” “https://api.monday.com/v2” -d ‘{“query”:“mutation{change_column_value(item_id:323796391, board_id:321744566, column_id: “Customer”, value:”\“Hello world\”“){name}}”}’

I am receiving the below error message:

Response Header

HTTP/1.1 401 Unauthorized Date: Sun, 15 Sep 2019 16:20:59 GMT Content-Type: application/json; charset=utf-8 Transfer-Encoding: chunked Connection: keep-alive Set-Cookie: __cfduid=dac7d794b02f898fa3de2443fee6aefc21568564459; expires=Mon, 14-Sep-20 16:20:59 GMT; path=/; domain=.monday.com; HttpOnly; Secure Status: 401 Unauthorized Vary: Origin Cache-Control: no-cache X-Request-Id: 58c52b37-c4cc-4b1f-a47f-c0de6481a57a X-Runtime: 0.012797 Expect-CT: max-age=604800, report-uri=“https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct” Server: cloudflare CF-RAY: 516bee5fd94ae0ce-IAD

Response Body

{“errors”:[“Not Authenticated”]}

Hey @kh2099
Have you tried using the try it yourself explorer with this token?
You can try it here: monday.com

Hi, @Ayelet
Tried the link u provided. getting below error:

{
“error_message”: “Internal server error”,
“status_code”: 500
}

Just to make sure, you need to copy the first token (under the API v2 Token title) using the copy button.
If this still doesn’t work try to hit regenerate to get a new token.
image

Did the same thing and still getting same error.

@Ayelet,
I noticed the below code works:

mutation {
create_item (board_id:321744566,
group_id:“Invoice”,
item_name:“new item 34”
{
id
}
}

but if I add the column_values, it does not:

mutation {
create_item (board_id:321744566,
group_id:“Invoice”,
item_name:“new item 34”
,column_values:{Customer:“Aramco”})
{
id
}
}

hey @kh2099,
I believe you are using the name of you column and not it’s ID.
please run this query to get the column ID:

query{
  boards(ids:  321744566){
    columns{
      id
      title
    }
  }
}

once you have the column ID this is how to correctly construct the mutation:

mutation {
  create_item (board_id:321744566,
    group_id:"Invoice",
    item_name:"new item 34",
    column_values:"{\"Customer_column_id\":\"Aramco\"})
    {
      id
    }
}

@Ayelet.

This is the output of the first query:

{
“data”: {
“boards”: [
{
“columns”: [
{
“id”: “name”,
“title”: “Name”
},
{
“id”: “text”,
“title”: “Customer”
},
{
“id”: “text6”,
“title”: “Project”
},
{
“id”: “status”,
“title”: “Status”
}
]
}
]
},
“account_id”: 4041551
}

Applying the 2nd query results in below:

mutation {
create_item (board_id:321744566,
group_id:“Invoice”,
item_name:“new item 34”,
column_values:"{“text”:“Aramco”})
{
id
}
}

getting below results:
{
“errors”: [
{
“message”: "Parse error on bad Unicode escape sequence: “{\\\“text\\\”:\\\“Aramco\\” (error) at [35, 19]”,
“locations”: [
{
“line”: 35,
“column”: 19
}
]
}
],
“account_id”: 4041551
}

removing the slashes:
mutation {
create_item (board_id:321744566,
group_id:“Invoice”,
item_name:“new item 34”,
column_values:{text:“something”})
{
id
}
}

getting:

{
“error_message”: “Internal server error”,
“status_code”: 500
}

The formatting in the community forum makes it hard to understand the issue.
Here is a snapshot from the try it yourself section of how your mutation should look like:
image

please try it in the try it yourself section and let us know if this works:

mutation {
  create_item (board_id:321744566,
    group_id:"Invoice",
    item_name:"new item 34",
    column_values:"{\"text\":\"Aramco\"}")
    {
      id
    }
}

@Ayelet.

Thanks, this one works.

@Ayelet
I need one more help from you.

Can u send me the syntax for CURL call (using above example)

@Ayelet, Hi. can u help me? this was my original request.

try this out:

curl -X POST -H "Content-Type:application/json" -H "Authorization:XXXXXXX" "https://api.monday.com/v2" -d '{"query":"mutation {create_item (board_id:321744566, group_id: \"Invoice\", item_name: \"new item 34\", column_values:\"{\\\"text\\\":\\\"Aramco\\\"}\"){ id }}"}'

@Ayelet, Hi. I tried this code. It is not working.

I tried also thru https://onlinecurl.com/ and getting the result below:
HTTP/1.1 401 Unauthorized Date: Mon, 23 Sep 2019 08:00:43 GMT Content-Type: application/json; charset=utf-8 Transfer-Encoding: chunked Connection: keep-alive Set-Cookie: __cfduid=d2da6b52efbdc24f70a1bf8b258282d371569225643; expires=Tue, 22-Sep-20 08:00:43 GMT; path=/; domain=.monday.com; HttpOnly; Secure Status: 401 Unauthorized Vary: Origin Cache-Control: no-cache X-Request-Id: c0070c56-85ce-441c-ab41-22b4ce01e949 X-Runtime: 0.021432 Expect-CT: max-age=604800, report-uri=“https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct” Server: cloudflare CF-RAY: 51aafc8f1ea5e0d2-IAD

Response Body

{“errors”:[“Not Authenticated”]}

I have tested this curl and it works for me. Since you are getting unauthorized error please make sure that you copy the API v2 token, it should look like so in your curl:
-H "Authorization:eyJ...................."

@Ayelet, I have used the same token for below site:

it is working. I copied in CURL link but failed to run.

Hey Khalid,

Dipro here, hopping in. Are you running this from a windows shell by any chance? I’ve heard from other users that windows environments don’t like single quotes, so you might have to experiment with replacing the single quotes ’ with double quotes " – and escape everything in between with backlashes.

Let me know if that helps!

Cheers,
Dipro

Hi,

The command given by Ayelet was having double quotes (no single quotes).

I tried also https://onlinecurl.com/. receiving the error message.

Hey Khalid,

Let’s step back a little. Can you try a simpler query and let me know if you get the same error? You can try passing this as the data:
{"query" : "{boards{id title}}"}

Let me know if that works and we can build from there.

Cheers,
Dipro

it is running in try-it-yourself site. failing in CURL.

I replaced ‘title’ with ‘state’. it was showing error.

this is my curl:

curl -X POST -H “Content-Type:application/json” -H “Authorization:xxxxx” “https://api.monday.com/v2” -d ‘{“query{boards{id state}}”}’