python example from documentation returns HTTP Error 401: Unauthorized

1,304 views
Skip to first unread message

michael petychakis

unread,
Apr 3, 2014, 4:53:57 PM4/3/14
to sta...@clarkparsia.com
Hello,

I am trying to create a python wrapper for some calls i need following the documentation here: http://docs.stardog.apiary.io/

My snippet is as follows:

from urllib2 import Request, urlopen

query = "select ?s ?f ?g where{?s ?f ?g}"
headers = {"SD-Query-Bindings": "", "SD-Connection-String": ""}
request = Request("http://localhost:5820/myDb/query", data=query, headers=headers)
response_body = urlopen(request).read()
print response_body

and as a response i get 
urllib2.HTTPError: HTTP Error 401: Unauthorized

Do you have any idea why?
Maybe I have to authorise the rest (http) interface without login through the administrator?

Regards,
Michael.
 

Mike Grove

unread,
Apr 4, 2014, 8:42:14 AM4/4/14
to stardog
On Thu, Apr 3, 2014 at 4:53 PM, michael petychakis <mpe...@gmail.com> wrote:
Hello,

I am trying to create a python wrapper for some calls i need following the documentation here: http://docs.stardog.apiary.io/

My snippet is as follows:

from urllib2 import Request, urlopen

query = "select ?s ?f ?g where{?s ?f ?g}"
headers = {"SD-Query-Bindings": "", "SD-Connection-String": ""}
request = Request("http://localhost:5820/myDb/query", data=query, headers=headers)
response_body = urlopen(request).read()
print response_body

and as a response i get 
urllib2.HTTPError: HTTP Error 401: Unauthorized

Do you have any idea why?

My python is a bit rusty, but you appear to be missing the username & password.
 
Maybe I have to authorise the rest (http) interface without login through the administrator?

Security is enabled by default; all requests to the server must be accompanied by a username & password.  These are handled via the normal HTTP auth mechanisms.

Cheers,

Mike
 

Regards,
Michael.
 

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

Reply all
Reply to author
Forward
0 new messages