I can’t figure out how to structure my json obj to update/create a tag based on the GraphQL documentation…
show: {
tag_name: showAbbr
},
show is the column id, showAbbr is a string
I can’t figure out how to structure my json obj to update/create a tag based on the GraphQL documentation…
show: {
tag_name: showAbbr
},
show is the column id, showAbbr is a string
See Tags
The create_or_get_tag is defining the tag on the board, if you want to set the flag to an item you should use the change_column_value mutation.
As @basdebruin said, you need to create or retrieve an existing tag using the following mutation:
mutation {
create_or_get_tag (tag_name: "my_tag") {
id
}
}
Then proceed with the regular mutation
mutation {
change_column_value (board_id: 123, item_id: 456 column_id: "tags", value: "{\"tags\" : {\"tag_ids\" : [789,123]}}") {
id
}
}
Just to let you know that there are currently a couple of bugs when you assign tags to an item thru API:
Monday devs (@dipro) are already aware of the problem.
Hey @ShawnBaden,
Thanks for reaching out! I believe we’ve also just been able to respond to this via email.
I really appreciate your help here, @rob and @basdebruin! Thanks so much for sharing your insights here.
Please let us know if the suggestions above help, Shawn We’d be glad to hear back from you.
-Alex
@rob , @AlexSavchuk
How does this look in Json format? If I’m sending variables to the mutation…
show: {
create_or_get_tag: {
tag_name: showAbbr
}
}
@ShawnBaden JSON syntax is not correct.
In addition, tag_name
must me an attribute of create_or_get_tag
options.
Here’s official documentation on how to create or get an existing tag:
https://developer.monday.com/api-reference/docs/tags-queries#create-or-get-a-tag
Once you get the tag ID, use it to assign a tag to an item:
https://developer.monday.com/api-reference/docs/tags
showAbbr
is a string it must be wrapped inside double quotes. I don’t know if it’s something you do later in your code;show
is not correct. You need to use mutation
.Thanks for adding onto this thread with more info
Here’s a Postman example that might help shed more light on this too:
{"query":"mutation {create_or_get_tag (board_id:yourBoardId, tag_name: \"your Tag Name\") {id}}"}
You can omit the Board ID field if you are creating a tag on a Main Board in your account.
I hope this helps.
-Alex
@rob @AlexSavchuk
Okay, here’s more of my code. What am I missing? I don’t know what the json syntax should be.
const variables = ({
boardId : suptBoardId,
groupId: "topics",
itemName : showAbbr + '_' + element,
columnValues: JSON.stringify({
text9: requestorName,
text0: email,
show: {
create_or_get_tag: {
tag_name: showAbbr
}
},
})
});
const query = `mutation create_item ($boardId: Int!, $groupId: String!, $itemName: String!, $columnValues: JSON!) {
create_item (
board_id: $boardId,
group_id: $groupId,
item_name: $itemName,
column_values: $columnValues
)
{
id
name
column_values {
id
title
value
text
}
creator {
id
name
teams {
id
name
}
}
board {
id
name
groups {
title
color
position
}
}
}
}`;
Thank you for circling back with me and sharing your code with us! I think I see what might be going astray here.
You will not be able to use “create_or_get_a_tag” as part of a “create_item” mutation. Those will need to be 2 separate calls, as mentioned earlier in the thread.
create_or_get_a_tag
mutation to get the Tag ID. This is where you can use the Postman example shared earlier, or examples from our documentation.It seems like currently you are trying to use both the create_item
and create_or_get_a_tag
mutations at once within the same API request, which isn’t possible at this time.
Does this help clarify? Please let me know.
-Alex
Thank you for the clarification.
This doesn’t seem very logical. Everything else seems to be divided into query or mutation while tags seem to do both. Makes for more work and more complicated code.
Thank you for your feedback. Since Tags can be both Public (exist on all Main Boards within your account) and Private (exist only within the Shareable/Private board they’re a part of), that does add an extra layer of complexity to using this feature via the API.
Either way, I’m glad to hear this makes a bit more sense now. Thank you for sticking with us to find the solution
-Alex
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.