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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials

question

Upvotes
Accepted
3 0 2 3

ThomsonReuters.Dss.Api.UnauthorizedException

I'm using the DataScope REST API toolkit for C#. On occasion when I run my application I get the following exception: ThomsonReuters.Dss.Api.UnauthorizedException: Authentication request failed because no token was provided in the Authorization: header.

When I rerun the application everything works as expected. Any ideas?

The latest toolkit, 12.3.361

The code is simplistic, it's straight out of the SDK tutorial.

_extractionsContext = new ExtractionsContext(new Uri(dssURI), dssUserName, dssUserPassword);
//create and populate the request
var result = _extractionsContext.ExtractWithNotes(request);
dss-rest-apidatascope-selectdssauthentication
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Hi @AlexL,

Could you share your application code and version of the SDK?

AlexL avatar image AlexL veerapath.rungruengrayubkul

The latest toolkit, 12.3.361

The code is simplistic, it's straight out of the SDK tutorial.

_extractionsContext = new ExtractionsContext(new Uri(dssURI), dssUserName, dssUserPassword);

//create and populate the request

var result = _extractionsContext.ExtractWithNotes(request);
Upvotes
Accepted
3 0 2 3

What seems to have solved the issue is accessing the SessionToken and simply logging in, just like the DSS .NET API Samples. I can't begin to explain why this does the trick however.

_extractionsContext.SessionToken
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
3 0 0 3

Hi @AlexL I guess you have to call your RequestToken method everytime you instantiate the application. Make sure that there is a valid Token whenever you perform new request.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Ian, based on the SDK tutorial, I instantiate an ExtractionsContext with the URI/login/password. Then I call ExtractWithNotes. I don't see RequestToken as a method available on the ExtractionContext.

@AlexL, what you do is correct. Instantiating the ExtractionContext is what logs you in. The token is managed transparently in the background for you, by the SDK, there is no need for you to manage the token.

Upvotes
13k 32 12 18

Could it be a race around condition - where the second request for ExtractWithNotes might be sent out, before the first call for RequestToken has returned or has failed.

If this is happening regularly, you can post a code snippet so that we can replicate the issue. Other option is to setup a proxy server to catch and inspect the raw request/response messages.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Gurpreet, please see the amended post with the code snippet. There is one call to ExtractWithNotes.

@AlexL, I have a feeling Gurpreet might be on to something here, maybe there is a race condition, because the request is sent out immediately after the ExtractionContext instantiation. Could you try adding a small wait (I'd go for 1 to 5 seconds, as a test) just after the ExtractionContext instantiation?

Upvotes
13k 32 12 18

The DSS .NET sample application has an example of ExtractWithNotes implementation in the Quick Start section. Do you observe this issue with the sample application as well?


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

I don't really run the sample app daily so I don't know.

@AlexL,

what Gurpreet is suggesting is to run different code, to see if it fails similarly.

Actually I'd recommend you try running one of the C# example codes (available under the downloads tab under ".Net SDK Tutorials code") several times in a row, and tell us if that also fails (it should not).

I recommend that instead of the C# example app described under the Quick Start tab because the C# example app requires a lot of manual actions, which will take more time, and will probably alleviate an eventual race condition.

Click below to post an Idea Post Idea