Symptoms:
The following error is seen when sending a notification to everyone endpoint:
ubuntu@pivotal-ops-manager:~$ uaac curl https://notifications.system.example.com/everyone -k -X POST --data '{"kind_id":"system-going-down","text":"The system is going down while we upgrade our storage","html":"<h1>THE SYSTEM IS DOWN</h1><p>The system is going down while we upgrade our storage</p>","subject":"Upgrade to Storage","reply_to":"########.io"}'
POST https://notifications.system.example.com/everyone
REQUEST BODY: "{"kind_id":"system-going-down","text":"The system is going down while we upgrade our storage","html":"<h1>THE SYSTEM IS DOWN</h1><p>The system is going down while we upgrade our storage</p>","subject":"Upgrade to Storage","reply_to":"########.io"}"
500 Internal Server Error
RESPONSE HEADERS:
Content-Length: 123
Content-Type: text/plain; charset=utf-8
Date: Thu, 07 Jul 2016 02:59:19 GMT
X-Cf-Requestid: 71771fc1-25db-####-####-0f5b81caa366
Connection: close
RESPONSE BODY: {"errors":["UAA Failure: 401 {\"error\":\"invalid_token\",\"error_description\":\"Invalid token (could not decode): \"}"]}
There is an issue with this version of the Notifications API when it is sent to everyone.
The workaround would be to enumerate all org levels and send an org-level email. The steps to do that can be found in this article, Send a notification to an organization.
Here is an example at the org level:
ubuntu@pivotal-ops-manager:~$ uaac curl https://notifications.system.example.com/organizations/68e6113f-f5bd-####-####-63107f91964b -k -X POST --data '{"kind_id":”system-going-down","text":"The system is going down while we upgrade our storage","html":"<h1>THE SYSTEM IS DOWN</h1><p>The system is going down while we upgrade our storage</p>","subject":"Upgrade to Storage","reply_to":"[email protected]"}' POST https://notifications.system.example.com/organizations/68e6113f-f5bd-####-####-63107f91964b REQUEST BODY: "{"kind_id":"system-going-down","text":"The system is going down while we upgrade our storage","html":"<h1>THE SYSTEM IS DOWN</h1><p>The system is going down while we upgrade our storage</p>","subject":"Upgrade to Storage","reply_to":"#######.io"}" 200 OK RESPONSE HEADERS: Content-Length: 371 Content-Type: text/plain; charset=utf-8 Date: Thu, 07 Jul 2016 06:15:12 GMT X-Cf-Requestid: 82f7ec94-90ca-####-####-1087b52b93e1 Connection: close RESPONSE BODY: [{"status":"queued","recipient":"11fc6635-0a06-####-####-6931fc50c830","notification_id":"ccb99ff7-b330-####-####-6a2d2036abe4","vcap_request_id":"57deedd8-7b0c-####-####-e075a6ca18d8"},{"status":"queued","recipient":"3714f579-920f-####-####-f6912b94fbb5","notification_id":"4bc36585-5653-####-####-7a716bb9c625","vcap_request_id":"57deedd8-7b0c-####-####-e075a6ca18d8"}]
Please note that in the version API 2.0 of notifications, the “everyone” endpoint feature will be removed.