question

Upvotes
Accepted
5 2 1 4

How to frame json request for fetching RIC values for multiple ISIN values using java?

This is the json request:

JSONObject searchJSONObject = new JSONObject();

searchJSONObject.put( "SearchRequest", new JSONObject()

.put("IdentifierType", "Isin")

.put("Identifier", new JSONArray().put("ISIN1").put("ISIN2"))

.put("PreferredIdentifierType", "Ric"));

I am getting the following error:

org.apache.http.client.HttpResponseException: Bad Request

Is this the correct way to frame the request? If not, how else can it be done?

tick-history-rest-apiisin
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.

@meera_c

Hi,

Thank you for your participation in the forum.

Are any of the replies below satisfactory in resolving your query?

If yes please click the 'Accept' text next to the most 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

Upvote
Accepted
13.7k 26 8 12

@meera_c, your code generates an array of instruments, but as pointed out by Veerapath, if you want several they should all be in a single string.

This is the request generated by the code in your query:

{"SearchRequest":{"PreferredIdentifierType":"Ric","Identifier":["ISIN1","ISIN2"],"IdentifierType":"Isin"}}

This is what is required:

{"SearchRequest":{"PreferredIdentifierType":"Ric","Identifier":"ISIN1, ISIN2","IdentifierType":"Isin"}}

So the code should be along these lines:

JSONObject searchJSONObject = new JSONObject()
    .put("SearchRequest", new JSONObject()
        .put("IdentifierType", "Isin")
        .put("Identifier", "ISIN1, ISIN2")
        .put("PreferredIdentifierType", "Ric"));

But again, as mentioned in my previous comment, using InstrumentSearch for more than 1 ISIN has severe limitations, I do not recommend using it that way.

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
13.7k 26 8 12

@meera_c, you can start by downloading the Java samples, available under the downloads tab. That will give you a good framework for experimenting, and a set of working requests. The samples are described in a readme file, and there is also some information here.

The programming without SDK tutorial explains how the HTTP requests that interact with the TRTH REST API are built in Java.

Finally, calls to convert ISINs to RICs are explained in full detail in this article.

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.

Thanks for the information! However, I was only able to find information regarding convertion of ISIN to RIC for a single ISIN in one json request. What I would like to know is, if its possible to convert multiple ISIN to RIC using a single json request?

@meera_c, that depends on the exact ISIN to RIC use case and call you use; some will take multiple ISINs, others will only take one.

For instance, if you want to find the current primary RIC for an ISIN, it is done using a T&C API call, which takes multiple ISINs, as illustrated in the article. Same goes for finding historical RICs for 1 or more exchanges using a historical reference call.

But the search calls (like the one in your query) only take one ISIN.

In the article, most of the cases where a call can take several ISINs, it is illustrated with several.

Upvotes
11.3k 25 9 14

I guess that the endpoint is InstrumentSearch. Please correct me if i'm wrong.

You can add multiple identifiers in the "Identifier" parameter with comma-separated.

The code should be:

.put("Identifier", "ISIN1,ISIN2")

For more information, please see the Search by RIC - HTTP request section in this tutorial.

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.

Thanks for your help! However i am still facing the same issue, that its not a valid json request.

Can you share the complete code section, so that we can identify the issue. You can also dump httpPost request messsage using something like:

System.out.println(httppost.toString());
for(org.apache.http.Header hdr : httppost.getAllHeaders())
    System.out.println(hdr);
httppost.getEntity().writeTo(System.out);

@meera_c, this will work ... up to a point. There are limitations:

  • The string that contains all the identifiers cannot exceed a length of 50 characters (if it does, an error will be returned).
  • The output is not configurable, and does not contain the input ISIN. As there are many RICs for an ISIN, you will not be able to easily map your input ISINs to the output RICs.

For ISIN to RIC conversion I would not use InstrumentSearch for more than 1 ISIN.

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.