Select to view content in your preferred language

Group.Notify() Exception - One or more users in the list are not allowed to receive notifications.

1555
3
10-20-2021 09:16 AM
ngrid_ShelbyZ
Occasional Contributor

Good Afternoon,

I'm attempting to send built in notifications to group members via collector using the arcgis.gis.Group.notify function.

I created a test group, and added a single member to the group to test. When I run the code block below, I get the following exception: I don't see anywhere in our organizational configuration, or documentation online where users can be configured to receive notifications. Does anyone know how to allow users to receive notifications, or potentially offer insight as to why this error is happening?

from arcgis.gis import GIS, Group, GroupManager
gis = GIS("home")
group = gis.groups.search('title: notify test group')
group = group[0]
group

members = group.get_members()
for user in members['users']:
    print (user)

group.notify(user, 'Notice!','Message Body', method = 'builtin', client_id= None)

 

 

Exception: Unable to send notification.
One or more users in the list are not allowed to receive notifications.
(Error Code: 400)
Tags (3)
0 Kudos
3 Replies
ABishop
MVP Regular Contributor

@ngrid_ShelbyZ 

When you added the member to the group, did you use an email that could have security block from unknown sender?  You may have to get your IT staff to allow this member to receive email from the server.  

Amanda Bishop, GISP
0 Kudos
joe_b
by
New Contributor

We had the same issue using the Python Group.notify() api on an AGOL notebook. The error messages seem to be misleading as I didn't have to change any user settings (AGOL or email) to get this working via the RESTful api.

I couldn't find the ArcGIS REST API documented for groups/createNotification. Looking at the ArcGIS JS REST library on github, I found the undocumented rest endpoint and called it directly via Python.

Here's the python:

import requests

from arcgis.gis import GIS
gis = GIS("home")

group = gis.groups.search(query='MyNotifyGroup')[0];
token = gis._con.token
url = 'https://www.arcgis.com/sharing/rest/community/groups/{}/createNotification'.format(group.groupid)

parms = {'f' : 'json',
         'users' : 'some.user@somedomain.com_somedomain',
         'subject' : 'The subject line...',
         'message' : 'This is the message body.',
         'method' : 'email',
         'token' : token
        }

response = requests.post(url, data = parms)

 

JSON response:

 

{
	"success": true
}

 

 

The notification shows in the alert area on the user's AGOL banner:

joe_b_0-1649360767773.png

In theory, SMTP is blocked from Python notebooks, so maybe the missing email is related to that restriction.

0 Kudos
TedHoward2
Esri Contributor

Calling REST directly is not necessary. The users parameter must be a list not a string.