Hi, Is there any way that we can alert based on the fault errors or exceptions? Please advice. Thanks!
Solved! Go to Solution.
Hi @Swapna,
By alerting if you are referring to sending out emails, then there's no such built in capability at the moment. Using fault handling policies you can handle various kinds of errors, but the fault rules would send out the error responses in the api response itself. In case you want to send out email alerts to a specific group upon an error you might want to try out the javascript or python callouts to do the same.
Here's one example:
import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText host = flow.getVariable("emailhost"); port = flow.getVariable("emailport"); username = flow.getVariable("emailusername"); password = flow.getVariable("emailpassword"); mailCC = flow.getVariable("emailcc"); mailTo = flow.getVariable("email"); bodyMessage = flow.getVariable("emailMessage"); subject = flow.getVariable("emailsubject"); mailFrom = flow.getVariable("emailfrom"); ssl = 'true'; auth = 'true'; msg = MIMEMultipart() msg['Subject'] = subject msg['From'] = mailFrom msg['To'] = mailTo msg['Cc'] = mailCC #msg['Bcc'] = mailBCC msg.attach( MIMEText(bodyMessage, 'html')) smtpserver = smtplib.SMTP(host,int(port)) if ssl=='true': smtpserver.ehlo() smtpserver.starttls() smtpserver.ehlo if auth=='true': smtpserver.login(username, password) smtpserver.sendmail(mailFrom, mailTo, msg.as_string()) smtpserver.quit()
You can set the smtp details and email address details either using flow variables or pre-defined in key value maps. This python script can then be attached to the python policy which can be invoked as part of your fault rules. However, please note that this is not a very scalable implementation and would lead to high email traffic on your smtp server. If you want to implement this on the cloud, then you might have to whitelist the message processor IPs on your smtp server.
There are a lot of ways to handle faults. Take a look at this page in the doc for more:
http://apigee.com/docs/api-services/content/fault-handling
Stephen
Hi @Swapna,
By alerting if you are referring to sending out emails, then there's no such built in capability at the moment. Using fault handling policies you can handle various kinds of errors, but the fault rules would send out the error responses in the api response itself. In case you want to send out email alerts to a specific group upon an error you might want to try out the javascript or python callouts to do the same.
Here's one example:
import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText host = flow.getVariable("emailhost"); port = flow.getVariable("emailport"); username = flow.getVariable("emailusername"); password = flow.getVariable("emailpassword"); mailCC = flow.getVariable("emailcc"); mailTo = flow.getVariable("email"); bodyMessage = flow.getVariable("emailMessage"); subject = flow.getVariable("emailsubject"); mailFrom = flow.getVariable("emailfrom"); ssl = 'true'; auth = 'true'; msg = MIMEMultipart() msg['Subject'] = subject msg['From'] = mailFrom msg['To'] = mailTo msg['Cc'] = mailCC #msg['Bcc'] = mailBCC msg.attach( MIMEText(bodyMessage, 'html')) smtpserver = smtplib.SMTP(host,int(port)) if ssl=='true': smtpserver.ehlo() smtpserver.starttls() smtpserver.ehlo if auth=='true': smtpserver.login(username, password) smtpserver.sendmail(mailFrom, mailTo, msg.as_string()) smtpserver.quit()
You can set the smtp details and email address details either using flow variables or pre-defined in key value maps. This python script can then be attached to the python policy which can be invoked as part of your fault rules. However, please note that this is not a very scalable implementation and would lead to high email traffic on your smtp server. If you want to implement this on the cloud, then you might have to whitelist the message processor IPs on your smtp server.
User | Count |
---|---|
7 | |
2 | |
2 | |
1 | |
1 |