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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials

question

Upvotes
Accepted
11 5 6 6

create a end of day template by REST API

I want to create a end of day template, my code as below:

JSONOrderedObject TAndCTemplateJSONObject = new JSONOrderedObject()

.put("@odata.type","#ThomsonReuters.Dss.Api.Extractions.ReportTemplates.ElektronTimeseriesReportTemplate")

.put("ShowColumnHeaders", false)

.put("Name", reportTemplateName)

.put("Headers", new JSONArray() )

.put("Trailers", new JSONArray() )

.put("ContentFields", new JSONArray()

.put( new JSONObject() .put("FieldName", "RIC") .put( "Format", JSONObject.NULL)) .put( new JSONObject() .put("FieldName", "Volume") .put( "Format", JSONObject.NULL) ) .put( new JSONObject() .put("FieldName", "Open Price") .put( "Format", JSONObject.NULL) ) .put( new JSONObject() .put("FieldName", "Low Price") .put( "Format", JSONObject.NULL) ) ) .put("Condition", JSONObject.NULL);

but Receive some error:

org.apache.http.client.HttpResponseException: Bad Request at org.apache.http.impl.client.AbstractResponseHandler.handleResponse(AbstractResponseHandler.java:70) at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:66) at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:52) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:223) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:165) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:140) at com.thomsonreuters.dss.api.example.DSS2ImmediateScheduleTermsAndCondition.createEODReportTemplate(DSS2ImmediateScheduleTermsAndCondition.java:471) at com.thomsonreuters.dss.api.example.DSS2ImmediateScheduleTermsAndCondition.main(DSS2ImmediateScheduleTermsAndCondition.java:101)

dss-rest-apidatascope-selectdssrest-apitemplate
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.

1 Answer

· Write an Answer
Upvotes
Accepted
11.3k 25 9 14

@chenchong

The HTTP 400 Bad Request normally is returned once the request message is incorrect. The error detail will be in the body of the status. Once the issue occurs, you may dump the request message body and try the message on another tool such as Postman to get error detail.

Anyway, please see the following comments on your code.

- Please ensure that the endpoint to create the ElektronTimeseriesReportTemplate is "/Extractions/ElektronTimeseriesReportTemplates".

- The "StartDate" and "EndDate" condition are required for this report template. You need to specify the date range of data to be extracted.

- The "Open Price" and "Low Price" fields are not valid for this report template. I think the "Open" and "Low" fields should be used instead. You can find all available fields in the Data Dictionary file.

Below is the sample code.

           HttpPost httppost = new HttpPost(urlHost + "/Extractions/ElektronTimeseriesReportTemplates");

httppost.addHeader("content-type", "application/json;odata.metadata=minimal");
httppost.addHeader("Authorization", "Token " + sessionToken);

 // Note: content fields are specific to each report template type
 JSONOrderedObject TAndCTemplateJSONObject = new JSONOrderedObject()

.put("@odata.type","#ThomsonReuters.Dss.Api.Extractions.ReportTemplates.ElektronTimeseriesReportTemplate")

.put("ShowColumnHeaders", false)

.put("Name", reportTemplateName)

.put("Headers", new JSONArray() )

.put("Trailers", new JSONArray() )

.put("ContentFields", new JSONArray()

.put( new JSONObject() .put("FieldName", "RIC") .put( "Format", JSONObject.NULL)) .put( new JSONObject() .put("FieldName", "Volume") .put( "Format", JSONObject.NULL) ) .put( new JSONObject() .put("FieldName", "Open") .put( "Format", JSONObject.NULL) ) .put( new JSONObject() .put("FieldName", "Low") .put( "Format", JSONObject.NULL) ) ) 

.put("Condition", new JSONOrderedObject()
                    .put( "StartDate", "2016-01-01T00:00:00.000-00:00" )
                    .put( "EndDate", "2016-02-01T00:00:00.000-00:00" ));

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 so much

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.