9 Replies Latest reply on Feb 21, 2010 9:21 PM by CJ

    Implement USPS Shipping Rate Calculator

    CJ

      I need to get rates for shipping from USPS, but I can not get the API to work. Below is the code and links to the page. Does anyone know of a tutorial or can help me figure out what the problem is. I only get HTTP Error 501 - Not Implemented

       

      USPS instructions: http://www.usps.com/webtools/htm/Rate-Calculators-v2-3.htm#_Toc220743995

       

      Page where the below code runs: http://www.wrathclothingstore.com/cfhttp.cfm

       

       

      CODE:


          <cfset strURL = (
          "http://testing.shippingapis.com/ShippingAPITest.dll?API=RateV3&XML="
          ) />

       

      <!--- Create the XML data to post. --->
      <cfsavecontent variable="strXML">
      <RateV3Request USERID="xxxxUserNameGoesHerexxxx">

       

          <Package ID="1ST">

       

              <Service>FIRST CLASS</Service>

       

              <FirstClassMailType>LETTER</FirstClassMailType>

       

              <ZipOrigination>44106</ZipOrigination>

       

              <ZipDestination>20770</ZipDestination>

       

              <Pounds>0</Pounds>

       

              <Ounces>3.5</Ounces>

       

              <Size>REGULAR</Size>

       

              <Machinable>true</Machinable>

       

          </Package>

       

          <Package ID="2ND">

       

              <Service>PRIORITY</Service>

       

              <ZipOrigination>44106</ZipOrigination>

       

              <ZipDestination>20770</ZipDestination>

       

              <Pounds>1</Pounds>

       

              <Ounces>8</Ounces>

       

              <Container>NONRECTANGULAR</Container>

       

              <Size>LARGE</Size>

       

              <Width>15</Width>

       

              <Length>30</Length>

       

              <Height>15</Height>

       

              <Girth>55</Girth>

       

          </Package>

       

          <Package ID="3RD">

       

              <Service>ALL</Service>

       

              <ZipOrigination>90210</ZipOrigination>

       

              <ZipDestination>96698</ZipDestination>

       

              <Pounds>8</Pounds>

       

              <Ounces>32</Ounces>

       

              <Container/>

       

              <Size>REGULAR</Size>

       

              <Machinable>true</Machinable>

       

          </Package>

       

      </RateV3Request>

      </cfsavecontent>



      <!---
          Post the XML data to catch page. We are going
          to post this value as an XML object will actually
          just post it as an XML body.
      --->
      <cfhttp
          url="#strURL#"
          method="POST"
          useragent="#CGI.http_user_agent#"
          result="objGet">

          <!---
              When posting the xml data, remember to trim
              the value so that it is valid XML.
          --->
          <cfhttpparam
              type="XML"
              value="#strXML.Trim()#"
              />

      </cfhttp>


      <!--- Output the return message. --->
      <cfoutput>

       

      CharSet: #objGet.ErrorDetail#<BR>
      Filecontent: #objGet.Filecontent#<BR>
      Header: #objGet.Header#<BR>
      Mimetype: #objGet.Mimetype#<BR>
      Statuscode: #objGet.Statuscode#<BR>
      Text: #objGet.Text#<BR>
      <!--- <cfdump var="#objGet#"> --->
      </cfoutput>

       

      Any help would be greatly appreciated. Been banging my head agaist the wall!!

       

      Thanks

      CJ