ContentsIntroductionThe CSR Service is used for searching for emails across account or batch. Search criteria can be email address or cpid, which returns a list of emails. A specific email can also be requested by record_id (returned in search results list). The MIME formatted email is returned for a specific email. Requests for resending a specific email or secure email password are also supported. Resent email or passwords can be sent to the original To address or a new, alternative address. The rendered text/plain or html email can be viewed with additional parameters. Errors may occur when bad credentials are supplied or incorrect/incomplete data is given in the CSR query. If you have not already done so, you should read the «ePriority Service Overview» before going further with this document as it will provide context for all ePriority features. HTTP QueryTo request a report through an HTTPS query, the following parameters must be supplied: AuthenticationThe cid (ePriority Client ID), authDate and authHash parameters are required for authentication of all Web API requests. See authentication instructions. Using the CSR ServiceSample Requests
https://www.epriority.com/EmailReports?version=1&cid=12345&authDate=2010-04-19T08:24:39&authHash=3ad64d6780d2c4762b335570646939e0&action=list&profile=Monthly_Statements&start=02/01/2010&stop=02/01/2010
https://www.epriority.com/EmailReports?cid=12345&authDate=1303224086377&authHash=cce48ea23edf7c97fa65bb1f2bd1b341&action=list&id=14KS2g9oiyLuE9JYQC&listsize=10
https://www.epriority.com/EmailReports?cid=12345&authDate=1303225511226&authHash=7f6038f801fb69cd9513a7a7d9a31482&action=list&addr=test.user@gmail.com&isRelayMail=true&listsize=5
https://www.epriority.com/EmailReports?cid=12345&authDate=1303224194210&authHash=381a47e16fb5d9f20ec99a556e3cdf68&action=record&record_id=2003009540_1
https://www.epriority.com/EmailReports?cid=12345&authDate=1303240706669&authHash=31701e5db9800e11619764aec833cba1&action=redeliver&isRelayMail=true&record_id=2003017997_8
Outputs
HTTP response 403 (forbidden) is returned when authentication fails. Successful List Request<?xml version="1.0" encoding="UTF-8"?> <root> <email_record> <record_id>2001056312_2</record_id> <address>epriority_test@dstoutput.com</address> <subject>This is a test message</subject> <client_id>1105</client_id> <batch_id>2001056312</batch_id> <client_batch_id>test1456295456</client_batch_id> <email_id>2</email_id> <cpid>acctnum45825647</cpid> <cpid2 /> <cpid3 /> <creation_date>2008-05-22 19:03:38.631000</creation_date> <delivered_date>2008-05-22 19:05:59.184318</delivered_date> <receipt_date /> <viewed_date>2008-05-22 19:06:29.184318</viewed_date> <replied_date /> <clicked_date /> <failed_date /> <failed_code>0</failed_code> <failed_description /> <profile_name>default</profile_name> <pprofileId>1001</pprofileId> </email_record> <email_record> <record_id>2001056310_1</record_id> <address>epriority_test@dstoutput.com</address> <subject>Welcome to Bank XYZ.</subject> <client_id>1105</client_id> <batch_id>2001056310</batch_id> <client_batch_id>new_cust_conf86458618</client_batch_id> <email_id>1</email_id> <cpid>acctnum45825647</cpid> <cpid2 /> <cpid3 /> <creation_date>2008-05-22 18:38:41.745000</creation_date> <delivered_date>2008-05-22 18:40:45.421363</delivered_date> <receipt_date /> <viewed_date>2008-05-22 18:49:45.421363</viewed_date> <replied_date /> <clicked_date /> <failed_date /> <failed_code>0</failed_code> <failed_description /> <profile_name>default</profile_name> <pprofileId>1001</pprofileId> </email_record> </root> Successful Record Request<?xml version="1.0" encoding="UTF-8"?> <root> <email_record> <record_id>2001056312_2</record_id> <address>epriority_test@dstoutput.com</address> <subject>This is a test message</subject> <client_id>1105</client_id> <batch_id>2001056312</batch_id> <client_batch_id>test1456295456</client_batch_id> <email_id>2</email_id> <cpid>2</cpid> <cpid2 /> <cpid3 /> <creation_date>2008-05-22 19:03:38.631000</creation_date> <delivered_date>2008-05-22 19:05:59.184318</delivered_date> <receipt_date /> <viewed_date>2008-05-22 19:06:29.184318</viewed_date> <replied_date /> <clicked_date /> <failed_date /> <failed_code>0</failed_code> <failed_description /> <profile_name>default</profile_name> <pprofileId>1001</pprofileId> <email> Date: Thu, 22 May 2008 14:03:38 -0500 (CDT) From: "Test" <test@dstoutput.com> Subject: This is a test message To: epriority_test@dstoutput.com Message-ID: <2001056312.2@testtracking.epriority.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MIMEBOUNDARY-MM0" Importance: 3 X-MSMail-Priority: Normal X-Priority: 3 User-Agent: eSolutions X-MimeOLE: Produced by eSolutions This is a MIME 1.0 compliant message. If you are able to see this message, your user agent is not MIME compliant. You will need an alternative mail viewer to read this message in its entirety. --MIMEBOUNDARY-MM0 Content-Type: multipart/alternative; boundary="MIMEBOUNDARY-MA0" --MIMEBOUNDARY-MA0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Dear ePriority Test, This is the text body of an e-mail message. ePriority Development Group DST Output, Inc. test=40dstoutput.com THIS IS THE TEXT BODY --MIMEBOUNDARY-MA0 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable <html> <body> <p>Dear ePriority Test,</p> <p>This is the body of an e-mail message.</p> <p>I am enclosing a secure html document entitled: secure.html</p> <p>Please download this document to your Desktop and open it using Inte= rnet Explorer.</p> <p>ePriority Development Group</p> <p>DST Output, Inc.</p> <p>test=40dstoutput.com</p> </body> </html> --MIMEBOUNDARY-MA0-- --MIMEBOUNDARY-MM0--</email> </email_record> </root> Unsuccessful Record Request (invalid record_id)<?xml version="1.0" encoding="ISO-8859-1"?> <root /> Successful Rendered Email ContentText/plain or HTML content of body with a text/plain or html mimetype accordingly. Unsuccessful Rendered Email Content<root> <status>FAILED</status> <message>Could not parse email</message> <root> Java Exampleimport java.io.*; import java.net.*; import java.text.*; import java.util.*; import java.security.MessageDigest; import javax.net.ssl.*; public class EpriorityCsrLookup { static int myAccountId = 12345; public static void main (String[] args) { try { // Prepare Authentication Credentials SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); sdf.setTimeZone(TimeZone.getTimeZone("Universal")); String authDate = sdf.format(new Date()); String webServicePw = args[0]; String searchAddress = args[1]; String digestString = authDate + webServicePw; MessageDigest md = MessageDigest.getInstance("SHA256"); byte[] hash = md.digest( digestString.getBytes() ); String hashHex = asHex( hash ); // Prepare Content StringBuilder content = new StringBuilder(); content.append("cid="); content.append(myAccountId); content.append("&authDate="); content.append(authDate); content.append("&authHash="); content.append(hashHex); content.append("&action=list"); content.append("&addr="); content.append(searchAddress); // Connect to URL URL url = new URL ("https://www.epriority.com/EmailReports"); URLConnection urlConn = url.openConnection(); urlConn.setDoInput(true); urlConn.setDoOutput(true); urlConn.setUseCaches(false); urlConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); // Send HTTP POST DataOutputStream printout = new DataOutputStream(urlConn.getOutputStream()); printout.writeBytes (content.toString()); printout.flush (); printout.close (); // Read XML Response BufferedReader input = new BufferedReader(new InputStreamReader(urlConn.getInputStream())); String str; while (null != ((str = input.readLine()))) { System.out.println(str); } input.close (); } catch (Exception e) { System.out.println(e.getMessage()); } } public static final String asHex(byte[] data) { //double size, two bytes (hex range) for one byte StringBuffer buf = new StringBuffer(data.length * 2); for (int i = 0; i < data.length; i++) { //don't forget the second hex digit if (((int) data[i] & 0xff) < 0x10) { buf.append("0"); } buf.append(Long.toString((int) data[i] & 0xff, 16)); } return buf.toString(); } } |