-
Notifications
You must be signed in to change notification settings - Fork 6
Description
USPS AMS only accepts 2-character (plus null-terminator) strings for the state field. This can be seen in zip4.h
typedef struct tagZip4Context
{
/*********** input data ***********/
...
char istai[2+1]; /* input state */
...
} ZIP4_PARM;
However, the api does not have this limitation on the state query parameter, which can lead to confusing results when sending a full state name. Ultimately, if a full state name is submitted, only the first 2 letters are used by USPS AMS. For example:
api/validate?&addr1=148+bennett+ave&city=waterbury&state=connecticut will return
...
"address" : {
"firm" : "",
"addr1" : "148 BENNETT AVE",
"addr2" : "",
"city" : "WATERBURY",
"state" : "CO",
"zip5" : "",
"zip4" : ""
}
...
Where it's using CO for the state, because those are the first 2 letters in Connecticut. However, that is the abbreviation for Colorado, not Connecticut, and therefore doesn't find a match for the address, even though the address does exist in Connecticut.
Full state names should be converted to their appropriate 2-letter abbreviations before submission to USPS AMS, when possible.