API Method MessageMark

From Updox API
Jump to: navigation, search

A method which sends a messageId and a boolean value from the authenticated user to server to mark the message as read or not. Boolean value equals true will mark the message as read, false will mark the message as unread.

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/MessageMark";
       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("messageId",(long)177985);
       messageData.put("read", 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

 {
   "messageId": "177985",
   "read": "true",
   "auth": {
       "applicationId": "updox",
       "applicationPassword": "password",
       "accountId": "updox_acct",
       "userId": "updox_user"
   }
 }

Response

{
   "successful": true,
   "responseMessage": "OK",
   "responseCode": 2000,
   "messageId": 177985,
   "read": true
}

Error Codes

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

responseCode responseMessage
4410 message not found