Hi Francesco, Thanks for help, and yes we want to have REST endpoint - I've tried the NotificationService to create notification, but got strange error (see the log below), and before notification creation I've called 'read' method of the MailTemplateService and successfully got template entity with key = "requestPasswordReset" and set this key to the notification creation request (NotificationTO) (see code snippet below). Could you please take a look at it, is it a syncope bug :
33971 [qtp1620216417-18] INFO o.a.c.i.LoggingOutInterceptor - Outbound Message --------------------------- ID: 2 Address: http://192.168.99.100:9080/syncope/rest/notifications Http-Method: POST Content-Type: application/json Headers: {Content-Type=[application/json], Accept=[application/json], Authorization=[Basic YWRtaW46cGFzc3dvcmQ=]} Payload: {"key":"111","abouts":{},"recipientsFIQL":null,"recipientAttrName":"emails","selfAsRecipient":false,"recipientsProviderClassName":null,"sender":"sen...@ukr.net","subject":"subject 1","template":"requestPasswordReset","traceLevel":"ALL","active":true,"events":[],"staticRecipients":[]} -------------------------------------- 34017 [qtp1620216417-18] INFO o.a.c.i.LoggingInInterceptor - Inbound Message ---------------------------- ID: 2 Response-Code: 500 Encoding: UTF-8 Content-Type: application/json;charset=UTF-8 Headers: {connection=[close], content-type=[application/json;charset=UTF-8], Date=[Thu, 24 Nov 2016 13:25:21 GMT], Server=[Apache-Coyote/1.1], transfer-encoding=[chunked], X-Application-Error-Info=[Unknown:InvalidStateException: The field "template" of instance "JPANotification[5b5da1d2-bbf5-49f7-9da1-d2bbf519f746]" contained a null value; the metadata for this field specifies that nulls are illegal.], X-Syncope-Domain=[Master]} Payload: {"status":500,"type":"Unknown","elements":["InvalidStateException: The field \"template\" of instance \"JPANotification[5b5da1d2-bbf5-49f7-9da1-d2bbf519f746]\" contained a null value; the metadata for this field specifies that nulls are illegal."]} -------------------------------------- MailTemplateTO mailTemplate = syncopeClient.getService(MailTemplateService.class).read("requestPasswordReset"); NotificationTO notificationTO = new NotificationTO(); notificationTO.setActive(true); notificationTO.setKey("111"); notificationTO.setRecipientAttrName("emails"); notificationTO.setSender("sen...@ukr.net"); notificationTO.setTemplate(mailTemplate.getKey()); notificationTO.setTraceLevel(TraceLevel.ALL); notificationTO.setSubject("subject 1"); Response rep = syncopeClient.getService(NotificationService.class).create(notificationTO); Thanks, Iurii Smyrnov ________________________________ From: Francesco Chicchiriccò <ilgro...@apache.org> Sent: Wednesday, November 23, 2016 3:08:52 PM To: user@syncope.apache.org Subject: Re: Syncope notifications Hi Iurii, first of all, have you already looked at https://syncope.apache.org/docs/reference-guide.html#notifications ? More replies below. Regards. On 23/11/2016 12:25, Iurii Smyrnov wrote: Hi Syncope team, Could you please help us, we've got few questions to you related to the Syncope built-in notification functionality: 1. Does Syncope have workflow to request(find) userNames by user email and send this userNames to his email ? 2. If no, is there a way to create a custom event (i.e. userName request), to associate it with a Notification (type email) and to initialize this event from outside of syncope (i.e. via Rest APIs) ? I don't think there is something similar; essentially, you'd want to add a REST endpoint, say GET /users/reminder?email=ilgro...@apache.org which looks for an user with e-mail 'ilgro...@apache.org<mailto:ilgro...@apache.org>', gets his username ('fchicchiricco') and sends an e-mail to ilgro...@apache.org<mailto:ilgro...@apache.org> with 'fchicchiricco' in the body. Correct? If so, you'll need to develop an extension for the purpose - from which you can leverage the existing Notification service. 3. Is there also a way to update syncope mail templates (requestPasswordReset and confirmPasswordReset) by using some REST APIs ? You can update such templates (and create more, actually) via both Eclipse IDE plugin and admin console: both rely only on REST to communicate with the core, hence the answer is yes. Take a look at the embedded Swagger UI (if extension is enabled) or REST reference available at http://syncope.apache.org/rest/2.0/index.html under /mailTemplates -- Francesco Chicchiriccò Tirasa - Open Source Excellence http://www.tirasa.net/ Member at The Apache Software Foundation Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail http://home.apache.org/~ilgrosso/