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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials

question

Upvotes
Accepted
45 11 21 14

Looking for dss rest api examples in visual basic (dot net)

Hi

I'm a newbie with the REST API, my past experience is with a competitor's web service. I'm a VB man, so any Visual Basic code would be welcome. What I have to achieve is retrieving ratings for securities and issuers and their parent companies.

Any help / hints welcome

Bernard

dss-rest-apidatascope-selectdssrest-api
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 @bernard.thouin,

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 reply. This will guide all community members who have a similar question. Otherwise please post again offering further insight into your question.

Thanks,

-AHS

Hello @bernard.thouin,

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 reply. This will guide all community members who have a similar question. Otherwise please post again offering further insight into your question.

Thanks,

AHS

BTh avatar image   BTh pimchaya.wongrukun01

Hi

My problem is that the 3 correct answers I needed have been given by @veerapath.rungruengrayubkul in comments to answers to my questions, so how can I accept his 3 comments as the proper answers to my problems ???

Hello @bernard.thouin,

Thank you for your comments.

We have converted the comments by @veerapath.rungruengrayubkul to answers.

Please click the 'Accept' text next to the appropriate reply, to help guide all community members who have a similar question.

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
11.3k 25 9 14

@bernard.thouin

I have tried to convert the C# code extracting Ratings to VB code using the code converters provided by Grupeet. The VB code works properly with a few changes. The code is attached.sample.zip You also need to add references to all DSS libraries (i.e. ThomsonReuters.Dss.RestApi.Client.dll, ThomsonReuters.Dss.Core.RestApi.Common.dll, etc)

If you still got error, please provide the code and error message.


sample.zip (1.1 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
22k 58 14 21

@bernard.thouin The DSS API come with a .NET library and example application with code snippets in C#. You can use one of the code converters to convert that code to VB.NET.

I would recommend downloading the sample application from DSS website and try out various API calls..

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.

Sorry, should have mentioned that I DID look at all sample applications, selected one (bond ratings), and tried to "convert" that one to VB... but quickly got stuck on the InstrumentIdentifierList.Create C# statement, where the code converter gets stuck with errors...:(

But I realize that, most probably, I would have to convert a lot of the underlying standard code to VB for the whole thing to work, so that looks that a never-ending attempt :(

Upvotes
32.2k 40 11 20

Hello @bernard.thouin,

In addition to the solid approach suggested by Gurpreet, here is some more info to code in VB against DSS REST service:

1. As you have dealt with REST web service before, from VB, the mechanics of making a REST request are likely familiar, however, online there are lots of materials discussing REST from VB, for example REST Example.

2. In terms of our Datascope rest web service, once you have your valid credentials assigned, there will be two steps:

a. First, pass to rest access point you assigned login and password, and get back a valid 'authentication token'.

b. Next, pass to rest access point your specific request (ratings request) with valid token and get back the requested content (ratings results).

These steps are fully covered in our online tutorials, I would recommend REST API Tutorials section for a quick and solid introduction.

3. Lastly, how to pinpoint and request ratings content. All the available requests, with parameters required and elaborated in REST API Reference Tree. Specifically, for Ratings, please review

Extractions -> Extraction Raw -> RatingsExtractionRequest

... to summarize, the tutorials have the complete request approach covered, while API Reference Tree will have the specifics on all the available requests, while Datascope Data Content Guide offers the complete reference of available content, fields and templates.

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 hints, especially about the REST API Reference Tree, which looks helpful.

As mentioned in my comment to the first answer, I'm getting unsure about using VB.net, as it looks a bit "mission impossible" to me to convert the example's code from C# to VB.

Upvotes
45 11 21 14

Hi guys

Thanks to @veerapath.rungruengrayubkul, I have a VB.Net version of the "Create Ratings" DSS example, and it works fine (after finding out how to add references to the Microsoft.OData.* DLLs...). However, the slightly anticlimax experience is that the example, which uses IBM.N as identifier (which is a stock, and not a bond, I think) is returning NO data whatsoever, neither from my VB code, nor from the sample example... (which hopefully indirectly proves that the VB code works fine :) ).

Now, I'd like to see some data returned, so what shall I use as a bond RIC that might return some useful data ?

Thanks for help

Bernard

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
11.3k 25 9 14

@bernard.thouin

You can search for bond RICs using the Gov/Corp Search UI. However, in this case, data likely is not returned because of the ReportDateRangeType.Range which is to identify the issuers/issues ratings that have updated during the specified date range. If the ReportDateRangeType is changed to ReportDateRangeType.Last, the extraction returns some data.

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 again

Thanks for the tip, I'll use that. I have, however, a problem with the

row.DynamicProperties.[Select](Function(dp) dp.Key & "=" + dp.Value) code. It throws an error on the only row returned:

System.InvalidCastException: 'Conversion from string " (" to type 'Double' is not valid.'

The only thing I changed Is the Ric code, I used US10YT, the US 10 year treasury bill.

Any idea what the cause could be ?

Regards

Bernard

Upvotes
11.3k 25 9 14

@berryardians

The issue is that row.IdentifierType returns Double data type, so VB tries to convert " (" string to double. To fix this issue, please add ToString() on row.IdentifierType to get String instead. Below is the sample code.

Debug.WriteLine(row.Identifier & " (" + row.IdentifierType.ToString() & ") " + String.Join(", ", row.DynamicProperties.[Select](Function(dp) dp.Key & "=" + dp.Value)))
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, it works, I should have thought about looking at the data type of the IdentifierType, but I thought the problem was in the dp function...

Now I'll try to make a more professional output so that I can save the fields and their values ultimately in an output table :)

Next step will be to build the identifier list from an input table. Is there some kind of Add InstrumentIdentifier to

InstrumentIdentifierList method, or how shall I go about that problem ?

Upvotes
11.3k 25 9 14

@bernard.thouin

The Add function is available. Below is the sample for adding two RICs. Your application can read identifiers from table and use the function to add them to the list.

Dim instrummentList = New InstrumentIdentifierList
instrummentList.InstrumentIdentifiers.Add(New InstrumentIdentifier With {.Identifier = "IBM", .IdentifierType = IdentifierType.Ric})
instrummentList.InstrumentIdentifiers.Add(New InstrumentIdentifier With {.Identifier = "TRI", .IdentifierType = IdentifierType.Ric})
Dim extractionRequest = New RatingsExtractionRequest With {
    .IdentifierList = instrummentList
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
45 11 21 14

@veerapath.rungruengrayubkul

Thanks for your last answer about filling the instrument list, that was the last missing piece (for the moment :)) !

regards

Bernard

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.