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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials

question

Upvotes
Accepted
3 2 1 5

InstrumentListsImportFromBytes request example

Hello,

I can't get /Extractions/InstrumentListsImportFromBytes working. Geting 400 Bad request all the time. I was not able to find any example for this method - example request would be helpful I guess.

API documentation says byte[] but there's no encoding mentioned, so I've asumed Base64. Here's my request:

{"FileBytes":"XXX==","Settings":{"ImportCreatedUserInstrumentsIntoList":true,"PredefinedAction":"Add","AllowDuplicateInstruments":true,"PredefinedName":"2016_09_13_09_47_39_tr_instrumentList.csv","ImportUserInstruments":true},"FileName":"2016_09_13_09_47_39_tr_instrumentList.csv"}

I was refering to this source:

https://hosted.datascopeapi.reuters.com/RestApi.Help/Context/Operation?ctx=Extractions&ent=InstrumentList&opn=ImportFromBytes

Thanks for any remarks.

Filip

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

Not including import and export examples was an oversight on our part. We have scheduled to include these examples in the 10.8 release.

Upvote
Accepted
11.3k 25 9 14

It seems that the FileBytes is in Base64 format. I am able to import an instrument list which contains "RIC,SAREUR=R" string in the imported file. Below is the message.

Post: https://hosted.datascopeapi.reuters.com/RestApi/v1/Extractions/InstrumentListImportFromBytes

{"FileBytes":"UklDLFNBUkVVUj1S", "Settings": {"ImportCreatedUserInstrumentsIntoList":true, "PredefinedAction":"Add", "AllowDuplicateInstruments":true, "PredefinedName":"test1", "ImportUserInstruments":true}, "FileName":"test1.csv" }
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

FileBytes must be in Base64 format.

If it is not (like XXX===) you will get the following error:

System.FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

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
3 2 1 5

Resolved. Thank You for the answers.

Using Veerapath's working request I was able to find that the issue elsewhere.

There's a typo in the API documentation:

/Extractions/InstrumentListsImportFromBytes vs

/Extractions/InstrumentListImportFromBytes

I should have read the response more carefully.

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 for pointing this out. The typo issue has been escalated to the relevant team.

Upvotes
13.7k 26 8 12

@filip.balas

Just a few additional thoughts:

Using this call you are storing an instrument list on the DSS server, permanently (well, until you decide to modify or delete it). This is mainly useful if you want to re-use the list later on. Storing an instrument list on the DSS server can be done in other ways, there are some examples in the tutorials here, in particular the REST API Tutorial 8 and the .Net SDK tutorial 2.

Depending on your use case, storing the list on the DSS server might not be required. Using On Demand queries you can pass the instrument list as a parameter, without storing it on the server. On Demand queries hide some of the complexity in the background, making you coding easier. To see examples of how that can be done, again refer to the tutorials here, in particular the REST API Tutorials 2 & 7, and the .Net SDK tutorials 6 & 7.

The best choice depends on what you are trying to achieve.

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.

Exactly crossed my mind when I moved to Extraction part. Thank You.

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.