I want to access an url which requires the full authentication. The following is my code.

import restclient

res = restclient.GET("x.x.x.x:8181/abc/def", headers = {'username':'admin','password':'admin'})

print res

400 Bad Request

Bad Request

Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.

Hint: https://unassigned-hostname:8181/

Please tell me how to do the full authenticated request using restclient module of python ?.

link|improve this question
feedback

1 Answer

If your service uses username and password headers for authentication (which I figured out by your example), your request should look like this:

from restclient import Resource

resource = Resource('https://x.x.x.x:8181')
result   = resource.get('/abc/def', headers = {'username':'admin','password':'admin'})

print result

The problem with your previous request was that you were sending plain text HTTP requests to a SSL-enabled port (HTTPS).

link|improve this answer
Thanks for the reply. I tried the above code but got an error message <restclient.errors.RequestError: (60, 'Peer certificate cannot be authenticated with known CA certificates')> – ameet Sep 20 '11 at 7:47
Looks like the REST service uses self-signed SSL certificates. I'm not that familiar with rest-client, but there should be some option allowing it to run wiht self-signed certificates. – Vladimir Blaskov Sep 20 '11 at 7:58
httplib2 of python has an option to disable ssl certificates, full authentication successful with httplib2 module of python. – ameet Dec 23 '11 at 8:21
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.