Difference between revisions of "API Method DirectMessageSend"
From Updox API
Line 3: | Line 3: | ||
== Fields == | == Fields == | ||
Please refer to the [https://updoxqa.com/iodox/updox-iodox Interactive API] for a list of the fields for this method. | Please refer to the [https://updoxqa.com/iodox/updox-iodox Interactive API] for a list of the fields for this method. | ||
+ | |||
+ | == Code Samples == | ||
+ | {| class="wikitable" style="width:900px; vertical-align:top; align:left" | ||
+ | ! Language || Source Code Examples | ||
+ | |- | ||
+ | | width="50px"| C# || <div class="mw-collapsible mw-collapsed" style="width:65px"> | ||
+ | |- | ||
+ | | align="top" | Java || <div class="mw-collapsible mw-collapsed" style="width:65px"> | ||
+ | <div class="mw-collapsible-content" style="width:810px"> | ||
+ | {{Talk To Updox - Core - Java|DirectMessageSend|DirectMessageSend}} | ||
+ | |||
+ | {{Json DirectMessageSend Block - Java}} | ||
+ | |||
+ | {{Base_Code_for_Consuming_API_Using_Java}} | ||
+ | |} | ||
== Sample Request and Response == | == Sample Request and Response == | ||
==== Request ==== | ==== Request ==== | ||
− | + | { | |
− | "to": | + | "to": "dublin@direct.updoxqa.com", |
− | + | ||
− | + | ||
"subject": "Test subject", | "subject": "Test subject", | ||
"textMessage": "Test message body", | "textMessage": "Test message body", | ||
Line 20: | Line 33: | ||
} | } | ||
], | ], | ||
− | + | "auth": { | |
"applicationId": "updox", | "applicationId": "updox", | ||
− | "applicationPassword": " | + | "applicationPassword": "password", |
− | "accountId": " | + | "accountId": "605", |
− | "userId": " | + | "userId": "605" |
} | } | ||
− | + | } | |
==== Response ==== | ==== Response ==== | ||
− | + | { | |
"successful": true, | "successful": true, | ||
"responseMessage": "OK", | "responseMessage": "OK", | ||
"responseCode": 2000, | "responseCode": 2000, | ||
− | + | "recipient": "contact:227683", | |
− | + | "name": "dublin@direct.updoxqa.com", | |
− | + | "directAddress": "dublin@direct.updoxqa.com", | |
− | + | "reason": null, | |
− | + | "messageId": 251802 | |
− | + | } | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | " | + | |
− | + | ||
== Error Codes == | == Error Codes == |
Revision as of 16:23, 2 December 2013
An outbound direct message method which sends a direct message (with optional attachments) from the authenticated user to one or more recipients.
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/DirectMessageSend"; 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(); List<String> to = new ArrayList<String>(); to.add("dublin@direct.updoxqa.com"); messageData.put("to",to); messageData.put("subject","Test Subject"); messageData.put("textMessage","Test message body"); List<Map<String,String>> attachments = new ArrayList<Map<String,String>>(); Map<String,String> attachment = new HashMap(); attachment.put("content", "CgoKCgoKCgoKCgoKCgoKCgoKCgoKVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1Qg VEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRF U1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lT QVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJ U0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1Qg VEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRF U1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lT QVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJ U0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1Qg VEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRF U1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lT QVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJ U0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1Qg VEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1Qg"); attachment.put("mimeType", "text/plain"); attachment.put("fileName", "test.txt"); attachments.add(attachment); Map<String,String>[] attachmentMap = attachments.toArray(new HashMap[attachments.size()]); messageData.put("attachments", attachmentMap); Map<String,String> authData = new HashMap(); authData.put("applicationId", "updox"); authData.put("applicationPassword", "password"); authData.put("accountId", "605"); authData.put("userId", "605"); 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
{ "to": "dublin@direct.updoxqa.com", "subject": "Test subject", "text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TQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1QgVEhJU0lTQVRFU1Qg", "mimeType": "text/plain", "fileName": "test.txt" } ], "auth": { "applicationId": "updox", "applicationPassword": "password", "accountId": "605", "userId": "605" }
}
Response
{ "successful": true, "responseMessage": "OK", "responseCode": 2000, "recipient": "contact:227683", "name": "dublin@direct.updoxqa.com", "directAddress": "dublin@direct.updoxqa.com", "reason": null, "messageId": 251802
}
Error Codes
In addition to the General Error Set, this method may return:
- 4640: direct address error: invalid direct address
- 4641: direct address error: no direct address found for this user
- 4650: direct error: send failed
- 4651: direct error: send failed and/or invalid direct address