I need specifically to make a POST request to their server as shown on page 12. However I continually get server error 500, and they FedEx support advised me that this means my request is incorrect somewhere.
I put the code I"m using at the end of this email. Unfortunately I don't know how to "see" the request the code generates either so I can't paste that here.
Ok, I tried the changes you guys suggested but same error still: 1. Corrected spelling of referrer. 2. Don't specify host.
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!
Here are some suspicions I have:
1 . One thing that is weird is that the data part just says "Your FedEx Transaction". I know I put the XML here, but I also notice that urllib2 is putting this as:
request=<xml ....
Can I have my xml placed here without that something= part? That don't specify what parameter name I should use.
2. urllib2 seems to create my request with \n\r line endings. Should it maybe just be \n? And if so, how to change that?
Gregory Piñero wrote: > Ok, I tried the changes you guys suggested but same error still: > 1. Corrected spelling of referrer. > 2. Don't specify host.
> 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!
"Referer" is the correct header name. The HTTP specification spells it incorrectly, so "Referrer" is the proper English spelling but invalid in the context of HTTP. This is for historical reasons, and is not likely to change.
> Here are some suspicions I have:
> 1 . One thing that is weird is that the data part just says "Your > FedEx Transaction". I know I put the XML here, but I also notice that > urllib2 is putting this as:
> request=<xml ....
> Can I have my xml placed here without that something= part? That > don't specify what parameter name I should use.
Are you sure it's supposed to be URL-encoded? Try just sending the XML data directly as part of the request.
Gregory Piñero wrote: > 1 . One thing that is weird is that the data part just says "Your > FedEx Transaction". I know I put the XML here, but I also notice that > urllib2 is putting this as:
> request=<xml ....
> Can I have my xml placed here without that something= part? That > don't specify what parameter name I should use.
you told it to do that:
values = {'request':xml_request} data = urllib.urlencode(values)
so if you don't want it, all you have to do is to pass in the transaction xml instead of the urlencoded form data:
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()