PAVv3 CF

From CDYNE Wiki for Web Services
Jump to: navigation, search

Calling Verify Address Advanced with a JSON body in cold fusion.

<cfscript>
      // use json.cfc from http://www.epiphantastic.com/cfjson/downloads.php instead of Coldfusion 8’s serializeJSON and deserializeJSON to preserve zipcode as a string.
      json = createObject("component","json");
      requestbody = StructNew();
      // use bracket notation to preserve case.
      requestbody['LicenseKey'] = 'your api key';
      requestbody[‘FirmNameOrRecipient’] = ‘CDYNE Corporation’;
      requestbody['PrimaryAddressLine'] = ‘2125 Smith Ave Ste 200’;
      requestbody['CityName'] = ‘Chesapeake’;
      requestbody['State'] = ‘VA’;
      requestbody['ZipCode'] = ‘23320’;
      requestbody['ReturnCaseSensitive'] = true;
      requestbody['ReturnMailingIndustryInfo'] = false;
      requestbody['ReturnResidentialIndicator'] = false;
      requestbody['ReturnLegislativeInfo'] = false;
      requestbody['ReturnCensusInfo'] = true;
      requestbody['ReturnGeoLocation'] = true;
</cfscript>
<cfhttp url="http://pav3.cdyne.com/PavService.svc/VerifyAddressAdvanced" method="POST" result="addressresult">
      <cfhttpparam type="header" name="accept" value="application/json" />
      <cfhttpparam type="header" name="content-type" value="application/json" />
      <cfhttpparam type="body" value="#json.encode(requestbody)#" />
</cfhttp>
<cfscript>
addressStruct = json.decode(trim(addressresult.fileContent));
      switch (addressStruct.ReturnCode) {
            case 1:
            case 2:
            case 10:
                  // Address Verification Failed
                  break;
case 101:
            case 102:
            case 103:
            case 200:
                  // Address Verification Succeeded
                  break;
      }     
</cfscript>
Personal tools
Toolbox





Trial Key