问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/24401227/troubleshooting-sparql-rcurl-queries-in-r