question

Upvotes
Accepted
3 0 0 1

Error in http_statuses[[as.character(status)]] : subscript out of bounds, when creating connection using DatastreamDSWS2R

When I am running the following using RStudio, I get the following error message. Can anyone help to fix the issue?


library('DatastreamDSWS2R')

options(Datastream.Username = 'XXXXXXX')

options(Datastream.Password = 'XXXXXXXX')

mydsws <- dsws$new()

Error in http_statuses[[as.character(status)]] : subscript out of bounds

datastream-apidsws-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.

Upvote
Accepted
78.6k 248 52 74

@stephen.guo

Thank you so much for the update.

It may relate to the status code 470. From this page, the status code 470 is still unassigned.

I think that this is why it shows the following error when processing the status code 470.

Error in http_statuses[[as.character(status)]] : subscript out of bounds 

From the error message: "Action: Deny. No rule matched. Proceeding with default action", it could be settings in the firewall that block this connection. You may need to contact your local IT support team to verify the problem.

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.

Many thanks! I think it makes sense.

Upvotes
24.6k 54 17 14

Hello @stephen.guo

I cannot replicate the issue with my R version 4.0.5, it can initialize a connection successfully.

Basically, the DatastreamDSWS2R is a wrapper API for the DataStream WebServices http://product.datastream.com API endpoint. Can you access the

http://product.datastream.com URL or http://product.datastream.com/DswsClient/v1/DSService.svc/rest/help from your network?

Additionally, the DatastreamDSWS2R is a 3rd Party library that not develop and maintain by Refinitiv, you may submit the issue in the GitHub issue page directly.


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.

Upvote
78.6k 248 52 74

@stephen.guo

You can run the below code to verify the problem.

library(httr)
DatastreamUsername <- "Username"
DatastreamPassword <- "Password"
token_url <- paste("http://product.datastream.com/DSWSClient/V1/DSService.svc/rest/Token?username=",
                   DatastreamUsername,
                   "&password=",
                  DatastreamPassword,
                   sep="")
test <- httr::GET(token_url, httr::timeout(300))
print(test)
print(status_code(test))
print(headers(test))
print(content(test))

After running, please remove your credential from the output and share it.

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 0 0 1

@jirapongse.phuriphanvichai

Many thanks for your help here! I have run your test code and getting the following results.


library('httr')

> DatastreamUsername <- "username"

> DatastreamPassword <- "password"

> token_url <- paste("http://product.datastream.com/DSWSClient/V1/DSService.svc/rest/Token?username=",

+ DatastreamUsername,

+ "&password=",

+ DatastreamPassword,

+ sep="")

> test <- httr::GET(token_url, httr::timeout(300))

> print(test)

Response [http://product.datastream.com/DSWSClient/V1/DSService.svc/rest/Token?username=username&password=password]

Date: 2021-05-19 06:14

Status: 470

Content-Type: text/plain; charset=utf-8

Size: 199 B


> print(status_code(test))

[1] 470

> print(headers(test))

$date

[1] "Wed, 19 May 2021 06:14:14 GMT"


$`content-length`

[1] "199"


$`content-type`

[1] "text/plain; charset=utf-8"


attr(,"class")

[1] "insensitive" "list"

> print(content(test))

[1] "HTTP request from 10.190.168.182:56148 to product.datastream.com:80. Url: product.datastream.com/DSWSClient/V1/DSService.svc/rest/Token. Action: Deny. No rule matched. Proceeding with default action"


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.

Upvote
24.6k 54 17 14

Hello @stephen.guo

The error message "Deny. No rule matched. Proceeding with default action " means your network blocks access to the DataStream API endpoint (product.datastream.com) .

I suggest you contact your IT Network team to help you.

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.

Many thanks! I think it makes sense.

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.