API Method MessageCountSince

From Updox API
Revision as of 15:55, 3 December 2013 by Frank (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

A method which is used to find every message since expected date for authenticated user.

Contents

Fields

Please refer to the Interactive API for a list of the fields for this method.

Code Samples

Language Source Code Examples
C#
Java


   public void TalkToUpdox() throws Exception {
       String uri = "https://updoxqa.com/io/MessageCountSince";
       ObjectMapper mapper = new ObjectMapper();
       Map<String,Object> messageData = BuildMessage();
       String jsonData = mapper.writeValueAsString(messageData);
       HttpResponse httpResponse = SendReceiveJSON(jsonData, uri);
       HttpEntity responseEntity = httpResponse.getEntity();
       String response = EntityUtils.toString(responseEntity);
       JsonNode actualObj = mapper.readTree(response);
 
       System.out.println(actualObj.get("responseCode"));
       System.out.println(actualObj.get("responseMessage"));
   }
 
   private Map<String,Object> BuildMessage() throws Exception
   {
       Map<String,Object> messageData = new HashMap();
       messageData.put("dateSince", "2013-03-20");
       messageData.put("countUnreadOnly","true");
       Map<String,String> authData = new HashMap();
       authData.put("applicationId", "updox");
       authData.put("applicationPassword", "password");
       authData.put("accountId", "updox_acct");
       authData.put("userId", "updox_user");
       messageData.put("auth", authData);
       return messageData;
   }
 
   private HttpResponse SendReceiveJSON(String jsonData, String uri) throws Exception {
       HttpClient httpClient = new DefaultHttpClient();
       HttpResponse response = null;
       StringEntity params = new StringEntity(jsonData);
       try {
           HttpPost request = new HttpPost(uri);
           request.addHeader("content-type", "application/json");
           request.setEntity(params);
           response = httpClient.execute(request);
       } catch (Exception ex) {
           // handle exception here
       } finally {
           httpClient.getConnectionManager().shutdown();
       }
       return response;
   }

Sample Request and Response

Request

 {
   "dateSince": "2013-03-20",
   "countUnreadOnly": "true",
   "auth": {
       "applicationId": "updox",
       "applicationPassword": "password",
       "accountId": "updox_acct",
       "userId": "updox_user"
   }
}

Response

{
   "successful": true,
   "responseMessage": "OK",
   "responseCode": 2000,
   "locations": [
       {
           "count": 28826,
           "location": "I"
       },
       {
           "count": 16,
           "location": "T"
       }
   ],
   "records": [
       {
           "count": 19,
           "type": "email"
       },
       {
           "count": 15,
           "type": "fax"
       },
       {
           "count": 28805,
           "type": "message"
       },
       {
           "count": 2,
           "type": "print"
       },
       {
           "count": 1,
           "type": "upload"
       }
   ],
   "count": 28842
}

Error Codes

In addition to the General Error Set, this method may return the following values in the responseCode and responseMessage fields:

responseCode responseMessage