/** * Create a Schedule */ public String createSchedule(String scheduleName) { String scheduleId = ""; try { System.out.println("Inside try"); String urlGet =urlHost + "/Extractions/Schedules"; Client client = Client.create(); WebResource webResource = client.resource(urlGet); JSONObject recurrence = new JSONObject(); recurrence.put("@odata.type", "#ThomsonReuters.Dss.Api.Extractions.Schedules.SingleRecurrence"); recurrence.put("IsImmediate",true); // reccurrence.put("ExtractionDateTime","2016-03-18T16:51:42.000Z"); JSONObject trig= new JSONObject(); trig.put("@odata.type", "#ThomsonReuters.Dss.Api.Extractions.Schedules.ImmediateTrigger"); JSONObject scheduleJSONObject = new JSONObject(); scheduleJSONObject.put("name",scheduleName); scheduleJSONObject.put("@odata.type", "#ThomsonReuters.Dss.Api.Extractions.Schedules.Schedule"); scheduleJSONObject.put("ListId","0x05321cff4db579e6"); scheduleJSONObject.put("OutputFileName","Immediate_extarct.csv"); scheduleJSONObject.put("Recurrence",recurrence ); scheduleJSONObject.put("ReportTemplateId","0x05330bf6e7eafc5b"); //scheduleJSONObject.put("ScheduleId","null"); scheduleJSONObject.put("TimeZone","(UTC+05:30) Chennai,Kolkata,Mumabi,New Delhi"); scheduleJSONObject.put("Trigger",trig); String params = scheduleJSONObject.toString(); System.out.println("Before print params"); System.out.println(params); System.out.println("After print params"); ClientResponse response = null; response = webResource .header("Content-Type", "application/json;charset=UTF-8") .header("Authorization", "Token " + sessionToken) .post(ClientResponse.class, params); System.out.println(response.toString()); System.out.println("After Response"); System.out.println("Before String.class"); String jsonStr = response.getEntity(String.class); System.out.println("aftre String.class"); JSONObject jsonResponse=new JSONObject(jsonStr); StringWriter out = new StringWriter(); jsonResponse.write(out); System.out.println("JSON response: "+ out); scheduleId = jsonResponse.getString("ScheduleId"); } catch (JSONException e) { e.printStackTrace(); } return scheduleId; }