urllib2 - My POST Request just isn't working right

Never Code Faster Than You Can See rarelychecked at gmail.com
Wed Feb 1 12:01:50 EST 2006


Gregory Piñero wrote:
> Ok, I tried the changes you guys suggested but same error still:
> 1. Corrected spelling of referrer.

errr, the other chap said the INcorrect spelling is correct for http. 
sorry about that.

> Here is what they say my request should look like:
> -------------------------------------------------------------------------
> POST /GatewayDC HTTP/1.0
> Referer: YourCompanyNameGoesHere
> Host: SSLserver.fedex.com
> Accept: image/gif, image/jpeg, image/pjpeg, text/plain, text/html, */*
> Content-Type: image/gif Content-length: %d
> 
> Your FedEx Transaction
> -------------------------------------------------------------------------
> Note that Host here is ficticious.  My host should be correct.  And
> they have referrer mispelled here so who knows which to use!

one oddity: they say here "SSL"
ie, a secure connection.

do you have to type in a password for your a/c when you look this info 
up manually on the web?

if so, you probably need a secure connection in the api too.

e.g. (copied out of my blogger code):
conn= httplib.HTTPSConnection(host)
conn.set_debuglevel(1)
conn.request("POST",path,body,headers)
response=conn.getresponse()
print response.read()

WHERE:
headers = { "Content-type"  : "application/xml"
            ,"Authorization" : basicstring
            ,"Host"          : host
           }

WHERE:
username="YOURACCOUNT"
pwd="YOURPWD"
host="SSLserver.fedex.com"
path="ANYTHINGAPPROPRIATE"
pwdDigest= base64.encodestring(username+":"+pwd).strip()
basicstring = "Basic "+ pwdDigest

altho chances are you'll have to fiddle with basicstring



More information about the Python-list mailing list