question

Upvotes
Accepted
36 4 6 10

Sample Tick History API java code below can be executed correctly, but no Template are obtained.

Sample Tick History API java code below can be executed correctly using code from Developers Portal RTH Java Code Examples, but no Template are obtained. Can you please advice.image002.png

https://developers.refinitiv.com/en/api-catalog/refinitiv-tick-history/refinitiv-tick-history-rth-rest-api/download

public void getAllReportTemplates() {
try {
String urlGet = "https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/ReportTemplates";
HttpGet request = new HttpGet(urlGet);
request.addHeader("Authorization", "Token " + sessionToken);
HttpResponse response = httpclient.execute(request);
System.out.println("Get all report templates. HTTP status: " + response.getStatusLine().getStatusCode());
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
StringBuffer result = new StringBuffer();
String line = "";
while ((line = rd.readLine()) != null) {
result.append(line);
}
System.out.println("Report Templates received:\n" + result);
JSONObject jsonGetResponse = new JSONObject(result.toString());
String userDetail = jsonGetResponse.get("value").toString();
System.out.println("All Report Templates:\n" + userDetail);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}

tick-history-rest-apijava
image002.png (29.2 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.

Hello @Vinod A ,

Thank you for your participation in the forum.

Is the reply below satisfactory in resolving your query?

If yes please click the 'Accept' text next to the appropriate reply. This will guide all community members who have a similar question. Otherwise please post again offering further insight into your question.

Thanks,

-AHS

Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,
AHS

Upvotes
Accepted
32.2k 40 11 20

Hello @Vinod A ,

This shows that the result is received, and it is of length 35537, it is not extraordinarily large, for example, my result from the same call is now of size 32538, so the question is why is the result not printed by the example code?

I would,

1. Verify that the example code downloaded from dev portal is run unmodified:

 HttpResponse response = httpclient.execute(request);

            System.out.println("Get all report templates. HTTP status: " 
                + response.getStatusLine().getStatusCode());

            BufferedReader rd = new BufferedReader(
                new InputStreamReader(response.getEntity().getContent()));

            StringBuffer result = new StringBuffer();
            String line = "";
            while ((line = rd.readLine()) != null) {
                result.append(line);
            }

            System.out.println("Report Templates received:\n"+result);

And this first result is empty?

2. Step through this code in debug mode in their IDE, try to find what readLine brings back?

3. As the says says "proxy", and original example output does not look like this, are they using a proxy and can it be the cause of the issue? Is it possible to re-test the example un-modified and without proxy use?

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.

Upvote
32.2k 40 11 20

Hello @Vinod A ,

I do not reproduce this issue on my side, with the latest RTH Java example deck from dev portal RTH Downloads. I receive all my report templates back (which is a lot).

Are you using the latest example from dev portal?

Are all the previous steps in the example working as expected on your side, and you are are able to create template, get template, delete template?

If yes, let me just guess here, do you have a tremendous number of report templates created under your user, and have you waited long enough?

If this could be the case, can you step-by-step through the code in your IDE, and see if its lingering in:

HttpResponse response = httpclient.execute(request);

If this is the case, I would test the same request from Postman, see how long it takes, and wait that time in Java, plus a add some extra time, for the overhead.

Let us know what you learn on your side?

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
36 4 6 10

Hi @zoya faberov

Client tried again, but still no data in the http response.

I printed the HttpResponse, could you please help to do some further exam.

1.png

2.png



1.png (18.8 KiB)
2.png (21.0 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.

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.