how do I query a inactive RIC int Tickhistory V2

bin
bin Explorer

HI

I try to build some Java code to schedule a task to question some inactive RIC but it looks dow not work I got bad request error. this is my java code, any help?

protected JSONArray getRICJsonArray(List<String> ric) {
JSONArray ricList = new JSONArray();
ric.forEach(e ->
ricList.put(new JSONObject()
.put("@odata.type", "#ThomsonReuters.Dss.Api.Search.HistorcalSearchResult")
.put("Description", "Historical Instrument")
.put("Identifier", e)
.put("IdentifierType", "Ric")
.put("FirstDate", "2006-01-01T00:00:00.000Z")
.put("LastDate", LocalDate.now().toString() + "T23:59:59.000Z")
));
return ricList;
}

@{"Identifiers":[{"LastDate":"2017-05-26T23:59:59.000Z","Description":"Historical Instrument","Identifier":"PETM.OQ","@odata.type":"#ThomsonReuters.Dss.Api.Search.HistorcalSearchResult","FirstDate":"2006-01-01T00:00:00.000Z","IdentifierType":"Ric"}],"KeepDuplicates":true}

if I replace JSONObject to JSONOrderObject I got

@{"Identifiers":["{\"@odata.type\":\"#ThomsonReuters.Dss.Api.Search.HistorcalSearchResult\",\"Description\":\"Historical Instrument\",\"Identifier\":\"PETM.OQ\",\"IdentifierType\":\"Ric\",\"FirstDate\":\"2006-01-01T00:00:00.000Z\",\"LastDate\":\"2017-05-26T23:59:59.000Z\"}"],"KeepDuplicates":true}

Both doesnot work any Idea?

Best Answer

  • zoya faberov
    zoya faberov ✭✭✭✭✭
    Answer ✓

    Hi @bin

    In Java, you may find the following code excerpt helpful

    HttpPost httppost = new HttpPost(urlHost + "/Search/HistoricalSearch");    
    httppost.addHeader("content-type", "application/json;odata.metadata=minimal");
    httppost.addHeader("Authorization", "Token "+sessionToken);
    JSONOrderedObject searchJSONObject = new JSONOrderedObject()
    .put("Request", new JSONOrderedObject()
    .put("Identifier", "PETM.OQ")
    .put("IdentifierType", "Ric")
    .put ("Range", new JSONOrderedObject()
    .put("Start", "2000-09-29T00:00:00.000Z")
    .put("End", "2017-09-29T00:00:00.000Z"))

    );

    it produces the following result for me:

    JSON response: {"@odata.context":"https://hosted.datascopeapi.reuters.com/RestApi/v1/$metadata#Collection(ThomsonReuters.Dss.Api.Search.HistoricalSearchResult)",
    "value":[{
    "Status":"Valid",
    "LastDate":"2015-03-14T00:00:00.000Z",
    "Identifier":"PETM.OQ",
    "Description":"Historical Instrument",
    "DomainCode":"6",
    "FirstDate":"2002-07-20T00:00:00.000Z",
    "InstrumentType":"Unknown",
    "History":[],"IdentifierType":"Ric","Source":"","Key":"...}]}

Answers