Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

USPS Rates API? 3

Status
Not open for further replies.

schase

Technical User
Sep 7, 2001
1,756
US
Hey all,

Has anyone had success using USPS's web tools for rates? Right now I use the below code. USPS tells me that the password is no longer looked for - or ignored if present.

I get the following returns - and I get the same return if i'm using the test server or the ssl server. And if I use post or get.

Code response is in this order: strXMLhttp.responseText, strXMLhttp.status, strXMLhttp.statusText

Code:
80040b19 XML Syntax Error: Error getting USERID attribute. UspsCom::DoAuth 
200
OK

Code:
<%
strXML= "<?xml version='1.0'?><RateV2Request USERID='xxxxxxxx'>"
strXML=strXML & "<Package ID='0'><Service>Priority</Service>"
strXML=strXML & "<ZipOrigination>10022</ZipOrigination>"
strXML=strXML & "<ZipDestination>20008</ZipDestination>"
strXML=strXML & "<Pounds>10</Pounds>"
strXML=strXML & "<Ounces>5</Ounces>"
strXML=strXML & "<Container>Flat Rate Box</Container>"
strXML=strXML & "<Size>REGULAR</Size>"
strXML=strXML & "</Package>"
strXML=strXML & "</RateV2Request>" 
Set strXMLhttp = Server.CreateObject("MSXML2.ServerXMLHTTP") 
strXMLhttp.Open "GET","[URL unfurl="true"]https://secure.shippingapis.com/ShippingAPITest.dll?API=RateV2&XML=",false[/URL] 
strXMLhttp.setRequestHeader "Content-Type", "application/x-[URL unfurl="true"]www-form-urlencoded"[/URL] 
strXMLhttp.send strXML
strResponseMessage = strXMLhttp.responseText
intHTTPStatusCode = strXMLhttp.status
strHTTPStatusText = strXMLhttp.statusText 
response.write strResponseMessage & "<BR>"
response.write intHTTPStatusCode & "<BR>"
response.write strHTTPStatusText & "<BR>"
%>

Thank you in advance.


Stuart
A+, Net+, Security+, MCP
 
What happens when you include a PASSWORD attribute, but leave it blank? That looks like it could be an error on their part. Ensure you are definately sending a USERID field, then send them a message. If nothing else, it's possible they are just spitting out the wrong error.

 
Same result when I try that. I called them and was told that they saw my checks went through successfully - go figure that one. So They told me to email the webtools place and see what they say.

I'm surprised at the almost complete lack of info on this over the net. I just basically modified the one I had for UPS.

But when i'm through this one I'll tackle Fedex - and then i'll post it as a FAQ so someone else may save themselves a little time.


Stuart
A+, Net+, Security+, MCP
 
alright

I put up as FAQ the code I used for USPS & UPS.

Hope it helps someone muddle through the mess that it can entail.


Stuart
A+, Net+, Security+, MCP
 
Use ASP to Get shipping rates from UPS. faq333-6359
Use ASP to get Shipping rates from USPS faq333-6360


-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
whoops, I forgot to post the links to my FAQ's. thanks George.


Stuart
A+, Net+, Security+, MCP
 
Doesn't get any better than this thread. Problem...solution..write a FAQ

Very nice style schase


General FAQ faq333-2924
5 steps to asking a question faq333-3811
 
Thanks Onpnt - how are you doing? You've helped me enough over the years to show how it's done :)




Stuart
A+, Net+, Security+, MCP
 
Yeah, that was before I knocked him off the top spot on the list for a couple years, then he just kinda slacked around in spot #2 until we both gave up our spots ;)

 
Hijack….

Yeah, I got used to sitting back letting Tarwn get it all right and playing second hand optional solutions to what always seemed to be the right way.

Seems lately google answers most of them though. Either that or my time issues sadly don't allow me to reply with the long threads I like so much



General FAQ faq333-2924
5 steps to asking a question faq333-3811
 
And added the one for FedEx

Use ASP to Get shipping rates from FedEx FAQ333-6397


Stuart
 
What about DHL? I happen to know that thewre is someone in this very forum that works there, so we could make lots of jokes about their system if you work on that one ;)

 
lol, I was thinking of DHL for the sake of getting the 4.

Just do not know if I'll use it for my own stuff.

Stuart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top