USPS : API Authorization failure
Asked Answered
C

3

11

Why won't the rate work with USPS? I'm using ratev4 and I get an error:

Error:

API Authorization failure. RateV4 is not a valid API name for this protocol.
UspsCom::DoAuth

Here is my code:

<?php
$devurl = "testing.shippingapis.com/ShippingAPITest.dll";
$puburl = "https://secure.shippingapis.com/ShippingAPITest.dll";

$service = "RateV4";
$userid = "690DEVBL1739";

$xml = rawurlencode('<RateV4Request USERID="xxxxx">
    <Revision/>
    <Package ID="1ST">
        <Service>FIRST CLASS</Service>
        <FirstClassMailType>LETTER</FirstClassMailType>
        <ZipOrigination>44106</ZipOrigination>
        <ZipDestination>20770</ZipDestination>
        <Pounds>1</Pounds>
        <Ounces>0.0</Ounces> 
        <Container/>
        <Size>REGULAR</Size> 
        <Machinable>true</Machinable>
    </Package>
    </RateV4Request>');

    $request = $devurl . "?API=" . $service . "&xml=" . $xml;


    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $request);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_HTTPGET, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);



    $response = curl_exec($ch);
    curl_close($ch);

    echo "<pre>";
    print_r($response);
    echo "</pre>";
Creech answered 2/4, 2012 at 1:38 Comment(3)
Why do you believe RateV4 should be valid?Jerejereld
The noPCommerce Forums suggests that the testing services haven't been updated to RateV4; though that posting is quite ancient. You might be best served by calling your USPS account representative and asking for clarification.Joycelynjoye
i have tried v3 and v2 and they produce the same problem. v2 is disabled so it doesnt work anymore.Creech
F
1

I've had the same issues with testing Ratev4 (and v2 for intl shipments) stuff. Just asking them to move you to production fixed that easily , but make sure you use the right urls of course. Other than that, from what I understand your setup wouldn't work anyway, because you're asking for a rate for first class and the weight is 1 pound. First class only goes up to 13 ounce...

Florineflorio answered 16/11, 2012 at 23:41 Comment(0)
M
9

I assume that you have already registered for USPS Web Tools here:

https://secure.shippingapis.com/registration/

And have received confirmation from USPS that your account is active:

If you need to set up USPS or your customers are receiving this error on check out (See below) you should confirm the following

Confirm that our USPS API access is approved

Confirm that it is not in test mode and is in production mode
    If USPS says your account is active, this does not mean it is in production mode, - you need to call USPS and specifically request that it be moved to production mode after your account has been approved. A good idea is to perform this quick test:

Insert the following into your browser with your own USERID in place of the XXXX in the URL of any browser:

https://secure.shippingapis.com/ShippingAPITest.dll?API=CarrierPick... USERID="XXXX">ABC Corp.Suite 7771390 Market StreetHoustonTX770581234

If your USPS account is active, it should accept the username.

Confirm that your username and password is for this site only. USPS only allows 1 domain per account.

http://production.shippingapis.com/ShippingAPI.dll

The problem is that by default, you don’t have access to USPS’s production API. They have to approve you first. Keep in mind that they only allow you to use it on one web site per account, so if you’re setting Magento up for a client, customer, or other business entity other than your own you should set up a separate USPS account for them.

That's why you're receiving this text - "Sample Do Not Mail" over the generated shipping label.

You can set up your USPS WebTools account here:

http://www.usps.com/webtools/

Once you have set up your account, they will give you access to the testing environment. The URL for the USPS test API is: http://testing.shippingapis.com/ShippingAPITest.dll

I recommend asking USPS to turn on production mode. When you are approved by USPS for the production API, you should use the following URLs:

http://production.shippingapis.com/ShippingAPI.dll

https://secure.shippingapis.com/ShippingAPI.dll

When you have completed your testing, email the USPS Internet Customer Care Center (ICCC). They will switch your profile to allow you access to the production server and will provide you with the production URLs.

The ICCC is staffed as follows: Monday through Friday from 8:00AM to 8:30PM Eastern Time Saturday from 8:00AM to 6:00PM Eastern Time Sunday and Postal Holidays - Closed except for the following Holidays: Martin Luther King; President's Day; Columbus Day; & Veteran's Day with hours from 9:00AM to 6:00PM Eastern Time

E-mail: [email protected] Telephone: 1-800-344-7779

But remember, it’s very important that you set up a separate USPS account for each web site (or at least one per domain). USPS will disable your access to their production server if you are caught using your account on multiple web sites.

To request access to the USPS production API, fill out the form here: http://www.usps.com/webtools/webtoolsapirequestform.htm

USPS doesn’t allow you to use their API for batch processing or data cleansing, so be sure to NOT check these boxes on the request form.

Once USPS gives you access to their production API server, everything should work corresponding to all USPS shipping options. If you are still having trouble, again check that you have access to USPS’s production API server.

Milkwort answered 16/1, 2015 at 6:58 Comment(1)
I am facing some issue consuming this API from my localhost (it is working for other environments like QA, Staging, Production). Any suggestion? This is the response "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 56.0.34.43:80"Numidia
S
5

I had the same problem. RateV4 is not valid for the USPS's test server, only production. I contacted their support people and tried to get a valid API for test but all they ever sent was a link to their documentation (which only contains production APIs, not test). In the end I just asked them to move my account to production and they did.

Scornful answered 27/6, 2012 at 20:56 Comment(1)
To do this, simply send an email to [email protected] with the message Please move User ID xxxxxx to the production serverTropic
F
1

I've had the same issues with testing Ratev4 (and v2 for intl shipments) stuff. Just asking them to move you to production fixed that easily , but make sure you use the right urls of course. Other than that, from what I understand your setup wouldn't work anyway, because you're asking for a rate for first class and the weight is 1 pound. First class only goes up to 13 ounce...

Florineflorio answered 16/11, 2012 at 23:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.