Skip to main content

Hello ,

I have very simple code using monday javascript sdk as below.



import mondaySdk from "monday-sdk-js";

const token ="mytoken";
const client = mondaySdk();
client.setToken(token);
client.setApiVersion("2023-10");
const res = await client.api(
`
query listGroups($boardId:ID!)
{
boards(ids : [$boardId])
{
groups{
id
title
}
}
}`,
{ boardId: "1835515014" }
);

console.log(res)


But i’m keep getting this error saying invalid value.


{
errors: :
{
message: 'Variable $boardId of type ID! was provided invalid value',
locations: :Array],
extensions: :Object]
}
],
account_id: 20529253
}

EDIT : I tested same graphql query using postman, it’s working fine there.

If anyone can help me with this?

Thanks.

The client.api method takes a query string as the first argument, the second argument is an object with multiple other parameters, one of those is variables. You need to pass the {boardId: "312312312"} as the variables parameter. See below for the edit:


import mondaySdk from "monday-sdk-js";

const token ="mytoken";
const client = mondaySdk();
client.setToken(token);
client.setApiVersion("2023-10");
const res = await client.api(
`
query listGroups($boardId:ID!)
{
boards(ids : [$boardId])
{
groups{
id
title
}
}
}`,
{variables:{ boardId: "1835515014" }}
);

console.log(res)

Thank you @anon29275264 ,

It’s working!!


Thank you @anon29275264 !!!


Reply