Can you please provide us a code on how to update sender language and the timezone of the sender account
January 3Created
January 21Last Updated
5 years agoLast Reply
1Replies
46Views
2Users
0Likes
0Links
Duo_Liang | Posts: 3776
Reply to: Update sender language and time zone
Thursday, January 3, 2019 at 08:53am
0
votes
Hi there,
For temporarily, timezone Id can be updated through Java SDK but not language, since these two settings are often be changed, you can use Rest API method instead.
Below is the sample code I created for you:
private void updateSenderLanguageAndTimezone(String api_url, String api_key, String senderId, String language,
String timezoneId) throws IOException {
URL sourceClient = new URL(api_url + "/account/senders/" + senderId);
HttpURLConnection sourceConn = (HttpURLConnection) sourceClient.openConnection();
sourceConn.setRequestProperty("Content-Type", "application/json; esl-api-version=11.21");
sourceConn.setRequestProperty("Accept", "application/json; esl-api-version=11.21");
sourceConn.setRequestProperty("Authorization", "Basic " + api_key);
sourceConn.setRequestMethod("POST");
sourceConn.setDoOutput(true);
sourceConn.setDoInput(true);
String payloadJSON = "{ \"language\": \"" + language + "\",\"timezoneId\": \"" + timezoneId + "\"}";
System.out.println(payloadJSON);
OutputStream os = sourceConn.getOutputStream();
os.write(payloadJSON.toString().getBytes());
os.flush();
os.close();
int sourceResponseCode = ((HttpURLConnection) sourceConn).getResponseCode();
if (sourceResponseCode != 200) {
Reader ir = new InputStreamReader(sourceConn.getErrorStream());
BufferedReader in = new BufferedReader(ir);
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
sourceConn.disconnect();
throw new RuntimeException(response.toString());
}
}
Sample Usage:
updateSenderLanguageAndTimezone("API_URL", "API_KEY", "sender_id", "fr", "GMT");
Reply to: Update sender language and time zone
Thursday, January 3, 2019 at 08:53am