Hi @kkocsis
Welcome to the community. I am using a function to send notifications.
static async sendNotification(token, userId, targetId, notificationText) {
try {
const mondayClient = initMondayClient({ token });
const query = `mutation create_notification($userId: Int!, $targetId: Int!, $notificationText: String!){
create_notification(user_id: $userId, target_id: $targetId, text: $notificationText, target_type: Project) {
text
}
}
`;
const variables = { userId, targetId, notificationText };
const response = await mondayClient.api(query, { variables });
return response;
} catch (err) {
console.log(err);
}
}
}
I am calling this function with:
mondayService.sendNotification(token, userId, boardId, notificationText);
The UserId here is the userId of the user who gets the notification.
Hope this helps.
Thanks @basdebruin, I can make it work, I just would like to know how I can send contextual data with a notification.
Hey @kkocsis - could you expand a bit on what you’re referring to by contextual data?
Hi @dsilva, I see you’ve recently responded to this so hopefully I can get some support from you guys.
Not to hijack the thread but I’m also getting 500’s with this query. Also want to give you a heads up that the documentation in https://monday.com/developers/v2#mutations-section-notifications is incorrect.
The example shows ‘project’ in lowercase, when it should be in upper case as the API rejects it otherwise.
Can you guys let me know if this API is broken or experiencing issues on your end? Here’s a snippet of our Python code that calls this
def notify_setter(self, msg, user_id):
query = 'mutation ' \\
'($user_id: Int!, $target_id: Int!, $msg: String!) ' \\
'{ ' \\
'create_notification (' \\
'user_id: $user_id, ' \\
'target_id: $target_id, ' \\
'text: $msg, ' \\
'target_type: Project' \\
') {text} }'
query_vars = {
'user_id': self.sender_id,
'target_id': user_id,
'msg': msg,
}
The resulting query string becomes:
'mutation ($user_id: Int!, $target_id: Int!, $msg: String!) { create_notification (user_id: $user_id, target_id: $target_id, text: $msg, target_type: Project) {text} }'
Apologies for the delay in response!
Are you still experiencing this issue? To confirm: I tested this out on my end and it seems to be working for me.
Thanks!
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.