I'm doing a sparql query against an authenticated endpoint in R using the SPARQL library.
The same query/endpoint/user works using the rrdf package. Unfortuantely, once I get the query working, I need to process the data in R and update the graph with the answers, which rrdf can't do.
Setting up a few variables first, the below query works using rrdf:
sparql.remote(myEndpoint,myQuery,'rowvar',myUsername,myUserpwd)
Using SPARQL, this does not work:
SPARQL(myEndpoint,myQuery,curl_args=c('username'=myUsername,'userpwd'=myUserpwd))
The error is Error: XML content does not seem to be XML: '' which I think means no document is coming back.
So, any tips on how to debug the curl call underneath all this?
And the solution in this case was that the username parameter is not used in curl.
The correct call is:
SPARQL(myEndpoint,myQuery,curl_args=c('userpwd'=paste(myUsername,':',myUserpwd,sep='')))
Actually debugging it was done via calls to getURL from RCurl against the basic endpoint until I got something that worked.
getURL(url=endpoint,userpwd="testusername:testpassword",verbose=TRUE)
Hope this helps someone.
Related
I want to use R package SPARQL to run set of INSERT queries to a Virtuoso endpoint.
How to give username and password to the function and which url to be used?
When I tried
tmpRes=SPARQL('myserver:8890/sparql',update=updateQry)
I got error: Error: SPARQL Request Failed
I think you want:
tmpRes=SPARQL('http://dba:dba#myserver:8890/sparql', query=updateQry)
note both changes.
HTH
The following document on Analyzing Linked Open Data with R shows how to query a Virtuoso SPARQL endpoint from R.
I am trying to connect to a socket.io data source using R.
Specifically I am trying to connect to CoinCap https://github.com/CoinCapDev/CoinCap.io.
I started by trying the websockets package from here but I could not get a connection. Maybe it is not socket.io compliant.
The best example appears to be in this post which asks the same question.
It seems the answer was to create a socket.io server as a middleman and then connect to R.
The problem is that I am not nearly as advanced as jeromefroe and have no experience with sockets or javascript and I have do not understand how the server that he created works or how to build or start it.
jeromefroe provides his javascript server code in the post, and I don't know what to do with it.
I am trying to collect data in R and use for analysis.
Can somebody help me get the connection running and/or help me set up the sever like jeromefroe did for the connection?
If I understand your question correctly, you are trying to "collect data in R and use for analysis". The website provides the REST URLs and so it is a matter of doing a http GET to retrieve data. An example usage of the httr package as follows. The result retrieved is in json format. Hence, you need jsonlite package to convert into a R data structure.
library(httr)
library(jsonlite)
resp <- httr::GET("http://coincap.io/coins")
jsonlite::fromJSON(rawToChar(resp$content))
I have an experiment in AzureML which has a R module at its core. Additionally, I have some .RData files stored in Azure blob storage. The blob container is set as private (no anonymous access).
Now, I am trying to make a https call from inside the R script to the azure blob storage container in order to download some files. I am using the httr package's GET() function and properly set up the url, authentication etc...The code works in R on my local machine but the same code gives me the following error when called from inside the R module in the experiment
error:1411809D:SSL routines:SSL_CHECK_SERVERHELLO_TLSEXT:tls invalid ecpointformat list
Apparently this is an error from the underlying OpenSSL library (which got fixed a while ago). Some suggested workarounds I found here were to set sslversion = 3 and ssl_verifypeer = 1, or turn off verification ssl_verifypeer = 0. Both of these approaches returned the same error.
I am guessing that this has something to do with the internal Azure certificate / validation...? Or maybe I am missing or overseeing something?
Any help or ideas would be greatly appreciated. Thanks in advance.
Regards
After a while, an answer came back from the support team, so I am going to post the relevant part as an answer here for anyone who lands here with the same problem.
"This is a known issue. The container (a sandbox technology known as "drawbridge" running on top of Azure PaaS VM) executing the Execute R module doesn't support outbound HTTPS traffic. Please try to switch to HTTP and that should work."
As well as that a solution is on the way :
"We are actively looking at how to fix this bug. "
Here is the original link as a reference.
hth
I try to use RGoogleDocs and get
Error: Forbidden
I have two-step verification on: is there a work-around?
sheets.con = getGoogleDocsConnection(getGoogleAuth(user, ps, service = "wise"))
Error: Forbidden
Relevant question
The getGoogleAuth of RGoogleDocs package is based on an officially deprecated ClientLogin to connect google server, see https://developers.google.com/identity/protocols/AuthForInstalledApps?csw=1
You may use the application password of google as a try.
Another way is just use the url of you google docs to visit certain contents, see http://www.r-bloggers.com/access-google-spreadsheet-directly-in-bash-and-in-r/
Update:
In the source code of getGoogleAuth, the author used an application called 'R-GoogleDocs-0.1', you may apply an new application and get the token. Then I think you could use the token and the api from google to access google docs directly in R. However, such hacks almost mean update/rewrite RGoogleDocs package.
I would like to use httr to link up/upload my R image outputs to flickr, but am having difficulty with the initial stages where i need to authenticate myself using OAuth 1.0.
I previously created an app by going to the following link http://www.flickr.com/services/apps/create/apply/
and then got a secret and key string for that app...
I then used it in the httr package function to get a token but to no avail. I have been trying to use the provided documentation on this link http://www.flickr.com/services/api/auth.oauth.html to help out but, I am struggling...
The following is the code I used.
flickr.app <- oauth_app("flickr",key="xxxxxx", secret="xxxxxxxx")
flickr.urls <- oauth_endpoint(request="http://www.flickr.com/services/oauth/request_token",
authorize="http://www.flickr.com/services/oauth/authorize",
access="http://www.flickr.com/services/oauth/access_token")
flickr.token <- oauth1.0_token(flickr.urls,flickr.app)
from which i get the error message
Error: http client error (400)
Not too sure where to go from here...any help would be much appreciated.
N.B. Also I recognise that due to the nature of setting up api links, that there are secrets , api-keys, logins and passwords that need to be kept secret etc, but it does not take long to set up a dummy flickr account from www.flickr.com , to be able to reproduce the problem...in my opinion...perhaps others could try setting one up and letting me know if they got similar issues, and potential methods to work around the situation?
I have never used the httr library, but I recently (as of yesterday) just finished writing from scratch Objective-C code to access Flickr. The biggest pain point for me was figuring out how to correctly encode the signature. I don't know the httr library well enough, but if I had to guess my guess would be that it is not encoding the signature properly.
If you read through this: http://www.flickr.com/services/api/auth.oauth.html
You will find very detailed instructions on how to authorize with Flickr - it was useful to me because I wrote the code in Objective C from scratch. Might be less useful to you unless you are able to debug through the httr source and figure out if it is doing things exactly as Flickr expects.