For a deeper look into our DataScope Select REST API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials

question

Upvotes
Accepted
3 4 3 7

Hiee Team:I am facing issues in creating schedule for DSS legal entity detail report template.Kindly provide the solution as I have been trying for many days.

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;
	}
 


Error I am getting is :
JSON response: {"error":{"innererror":{"message":"\n\nMapping types:\r\nSchedule -> ScheduleDescription\r\nThomsonReuters.Dss.Extractions.Schedules.Schedule -> ThomsonReuters.Dss.Extractions.Schedules.ScheduleDescription\n\nDestination path:\nScheduleDescription\n\nSource value:\nSchedule - ID: 0x053354546cf52703","internalexception":{"message":"Value cannot be null.\r\nParameter name: name","stacktrace":"   at ThomsonReuters.Dss.Extractions.Schedules.ScheduleDescription..ctor(String name, String outputFileName, String timeZone, ScheduleContent content, ScheduleRecurrence recurrence, ScheduleTrigger trigger)\r\n   at ThomsonReuters.Dss.Extractions.Schedules.Schedule.<.cctor>b__0(Schedule s)\r\n   at AutoMapper.MappingExpression`2.<>c__DisplayClass12.<ConvertUsing>b__11(ResolutionContext source)\r\n   at AutoMapper.Mappers.TypeMapObjectMapperRegistry.CustomMapperStrategy.Map(ResolutionContext context, IMappingEngineRunner mapper)\r\n   at AutoMapper.Mappers.TypeMapMapper.Map(ResolutionContext context, IMappingEngineRunner mapper)\r\n   at AutoMapper.MappingEngine.AutoMapper.IMappingEngineRunner.Map(ResolutionContext context)","type":"System.ArgumentNullException"},"stacktrace":"   at ThomsonReuters.Dss.Extractions.Schedules.Schedule.BeforeSave(IList`1 warningAndInfoMessages)\r\n   at ThomsonReuters.Dss.Core.Entities.ContextBase.DoBeforeSaveChanges(IList`1 warningAndInfoMessages)\r\n   at ThomsonReuters.Dss.Core.Entities.ContextBase.Validate(IList`1 warningAndInfoMessages)\r\n   at ThomsonReuters.Dss.Core.Entities.ContextBase.SaveChanges()\r\n   at ThomsonReuters.Dss.Core.RestApi.Controllers.ContextBatchHandler.SaveChanges()\r\n   at ThomsonReuters.Dss.Api.Extractions.Schedules.SchedulesBaseController.CreateEntity(Schedule entity)\r\n   at ThomsonReuters.Dss.Core.RestApi.Controllers.EntitySetController`2.Post(TEntity entity)\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()","type":"AutoMapper.AutoMapperMappingException"},"message":"\n\nMapping types:\r\nSchedule -> ScheduleDescription\r\nThomsonReuters.Dss.Extractions.Schedules.Schedule -> ThomsonReuters.Dss.Extractions.Schedules.ScheduleDescription\n\nDestination path:\nScheduleDescription\n\nSource value:\nSchedule - ID: 0x053354546cf52703","code":""}}	
dss-rest-apidatascope-selectdssjava
schedule-issue.txt (2.4 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thank you for your participation in the forum. Are the replies below satisfactory in resolving your query? If so, can you please click the 'Accept' text next to the most appropriate reply. This will guide all community members who have a similar question. Thanks and kind regards,

AHS

Upvote
Accepted
582 9 15 23

The error message is pointing to a null value for the 'name' parameter (which is the Schedule name). And you'd provided the Schedule Name in the code; so probably the order of the parameters in the JSON Request had been reshuffled. Attached it's an example of creating a Schedule for the Legal Entity Report (see the 'createReportSchedule' method). (dss2legalentitydetailreportscheduleclient.zip)


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

This new sample has just been added to the Java Code Examples package.

Upvotes
13.7k 26 8 12

I don't have a Java environment installed, so I can't test your code. But the error message contains an internal exception with this message: "Value cannot be null.\r\nParameter name: name".

This tells us the name parameter has a null value, which should not be the case. It is set in this line of your code:

scheduleJSONObject.put("name",scheduleName);

scheduleName is the input parameter of createSchedule.

How was createSchedule called ? Was a value assigned to scheduleName ? What value ?

To test if scheduleName is null or has a value I'd try adding the following line inside the try code block:

System.out.println("scheduleName: " + scheduleName);

As a test you could also replace the variable scheduleName with a hard coded string:

scheduleJSONObject.put("name", "myScheduleName");

That might help you find the source of the error.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Dear Christiaan Meihsl,

This is not the issue ,I am providing the value to schedule name it's not null .I am not getting which name is refered in the error.

Upvotes
13.7k 26 8 12

Looking at your code again, I see that name does not start with a capital N. Try this:

scheduleJSONObject.put("Name",scheduleName);
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi..Christiaan Meihs --This thing also i have tried..this is not the issue the issue is with the request ...AS i am getting bad request error..the parameters I am passing is not in synchronization with ,what the service needs,but there is no such documentation where i can get what to pass and which format to use.

Upvotes
18.2k 21 13 21

Attach an example to get Leget Audit data from DSS REST API.
You will need to download libs from http://hc.apache.org/downloads.cgi
Please add reference to commons-logging-1.2.jar, httpclient-4.5.2.jar and httpcore-4.4.4.jar to your project to run this sample code.
You also have to pass 2 parameter to the app which are DSS login ID and password.dss-rest-test.zip


dss-rest-test.zip (51.3 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
966 11 21 26

Have you looked at the Sample application available in the DSS REST API Downloads page here. It has many samples including how to create a schedule. The C# might not be that useful for you because it uses the SDK, but you can see the HTTP request and response. Once you have the JSON required for the request, you should be able to build that in Java

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
966 11 21 26

From the sample app the request to create a schedule under Scheduled Extractions | Immediate, is

POST https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/Schedules HTTP/1.1
Authorization: Token <your_auth_token_goes_here>
X-Client-Version: restapiv1.10.2.884.0
Prefer: respond-async
{
    "Name": "ImmediateNonCustomized",
    "TimeZone": "GMT Standard Time",
    "Recurrence": {
        "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.Schedules.SingleRecurrence",
        "ExtractionDateTime": "2016-03-31T10:03:34.926Z",
        "IsImmediate": true
    },
    "Trigger": {
        "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.Schedules.ImmediateTrigger",
        "LimitReportToTodaysData": true
    },
    "ListId": "0x0534033979eafc5b",
    "ReportTemplateId": "0x0534033aee9a2eab"
}

Your request looks like this

{
    "name": "LegalEntity_SCHEDULE2",
    "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.Schedules.Schedule",
    "ListId": "0x05321cff4db579e6",
    "OutputFileName": "Immediate_extarct.csv",
    "Recurrence": {
        "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.Schedules.SingleRecurrence",
        "IsImmediate": true
    },
    "ReportTemplateId": "0x05330bf6e7eafc5b",
    "TimeZone": "(UTC+05:30) Chennai,Kolkata,Mumabi,New Delhi",
    "Trigger": {
        "@odata.type": "#ThomsonReuters.Dss.Api.Extractions.Schedules.ImmediateTrigger"
    }
}


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.