Internal Server error

Diez B. Roggisch deets at nospam.web.de
Sun Feb 8 09:45:33 EST 2009


zaheer.agadi at gmail.com wrote:

> On Feb 8, 4:09 pm, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
>> zaheer.ag... at gmail.com schrieb:
>>
>>
>>
>> > HI
>> > I am getting an internal server error while trying get response from a
>> > server following is my code
>>
>> > def getDetails(self,username,password):
>> > urllib = urllib2.Request
>> > idurl="https://some.server.com/"
>> > port=8181
>> > conn = httplib.HTTPSConnection("some.server.com/",8181);
>> > conn.debuglevel  = 1
>> > username = "userone"
>> > password = "aaaa"
>> > Auth = "Basic" + ecnodeURL(self,username, password)
>> > url= "https://some.network.com:8181/main/folder/persons/" +
>> > username + "/attributes/atrone"
>> > print url
>> > headers = {"Authorization": Auth,"Accept": "application/json"}
>> > conn.request("GET", url,{},headers)
>> > response = conn.getresponse()
>> > data = response.read()
>> > print response.reason
>> > print response.

> Thanks,
> 
> I know there is something on the wrong side, when it says
> java.util.NoSuchElementException i  thought something wrong with
> setting values I just wanted you guys to point me out  there is
> something wrong with the code I have written I am not very familiar
> with Python the same work for java works fine.

Well, it's obviously not the same. Otherwise it *would* work fine as well.

your code is a bit non-idiomatic:

urllib = urllib2.Request

is *very* misleading, aliasing a class-constructor with a well-known
modulename.

Not using username & password also isn't really making sense.

"ecnodeURL" - what is that? Where does that come from - certainly not from
the stdlib, that's got a better spelling correction.

Instead of 

"string" + variable + "string"

on usually uses string interpolation to build complicated strings:

"some text %s some more text" % variable



> 
> I wanted to know if I am setting the headers correctly, getting the
> response correctly
> are there any better ways of encoding the url Over all Does the code
> look ok...?

You seem to make the call correctly. Just not what the server expects.

Diez




More information about the Python-list mailing list