{"id":1633,"date":"2022-11-05T11:33:05","date_gmt":"2022-11-05T11:33:05","guid":{"rendered":"https:\/\/serviceobjects.wpaladdin.com\/?post_type=serviceobjects&#038;p=1633"},"modified":"2024-03-29T14:12:56","modified_gmt":"2024-03-29T21:12:56","slug":"ad-rest","status":"publish","type":"page","link":"https:\/\/test.serviceobjects.com\/docs\/dots-address-detective\/ad-code-snippets-and-sample-code\/ad-rest\/","title":{"rendered":"AD &#8211; REST"},"content":{"rendered":"\n<div class=\"wp-block-create-block-tabs\"><ul class=\"tab-labels\" role=\"tablist\" aria-label=\"tabbed content\"><li class=\"tab-label active\" role=\"tab\" aria-selected=\"true\" aria-controls=\"C#\" tabindex=\"0\">C#<\/li><li class=\"tab-label\" role=\"tab\" aria-selected=\"false\" aria-controls=\"Java\" tabindex=\"0\">Java<\/li><li class=\"tab-label\" role=\"tab\" aria-selected=\"false\" aria-controls=\"PHP\" tabindex=\"0\">PHP<\/li><li class=\"tab-label\" role=\"tab\" aria-selected=\"false\" aria-controls=\"RoR\" tabindex=\"0\">RoR<\/li><li class=\"tab-label\" role=\"tab\" aria-selected=\"false\" aria-controls=\"Python\" tabindex=\"0\">Python<\/li><li class=\"tab-label\" role=\"tab\" aria-selected=\"false\" aria-controls=\"ColdFusion\" tabindex=\"0\">ColdFusion<\/li><li class=\"tab-label\" role=\"tab\" aria-selected=\"false\" aria-controls=\"VB\" tabindex=\"0\">VB<\/li><li class=\"tab-label\" role=\"tab\" aria-selected=\"false\" aria-controls=\"TSQL\" tabindex=\"0\">TSQL<\/li><li class=\"tab-label\" role=\"tab\" aria-selected=\"false\" aria-controls=\"NodeJS\" tabindex=\"0\">NodeJS<\/li><\/ul><div class=\"tab-content\">\n<div class=\"wp-block-create-block-tab tab-panel\" role=\"tabpanel\" tabindex=\"0\">\n<p><strong>Address Detective C# Code Snippet<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"csharp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">string mainURL = TrialURL+ address1 + \"\/\" + address2 + \"\/\" + city + \"\/\" + state + \"\/\" + postalCode + \"\/\" + businessName + \"\/\" + phoneNumber + \"\/\" + fullName + \"\/\" + firstName + \"\/\" + lastName + \"\/\" + licenseKey;\n ADResponse result = null;\ntry\n{\n    result = HttpGet(mainURL);\n    \/\/NULL ERROR || FATAL ERROR RETURNED -- TRY BACKUP\n    if (result == null || (result.error != null &amp;&amp; result.error.TypeCode == \"3\"))\n     {\n     return HttpGet(backupURL);\n     }\n else\n {\n    return result;\n }\n}\n   \nprivate ADResponse HttpGet(string requestUrl)\n{\n  try\n  {\n   \/\/NOTE: URL encoding occurs automatically when creating the web request\n   HttpWebRequest request = WebRequest.Create(requestUrl) as HttpWebRequest;\n   request.Timeout = WEB_SERVICE_REQUEST_TIMEOUT;\/\/timeout for get operation\n   \n  using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)\n    {\n       if (response.StatusCode != HttpStatusCode.OK)\n         throw new Exception(String.Format(\n         \"Server error (HTTP {0}: {1}).\",\n          response.StatusCode,\n          response.StatusDescription));\n  \n          \/\/parse response\n          DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(ADResponse));\n          object objResponse = jsonSerializer.ReadObject(response.GetResponseStream());\n          ADResponse jsonResponse = objResponse as ADResponse;\n          return jsonResponse;\n     }\n   }\n}\n  \n private void ProcessResponse(ADResponse response)\n        {\n            try\n            {\n                \/\/processing result\n                if (response.error == null)\n                {\n                    ProcessResult(response);\n                }\n                \/\/processing error\n                else\n                {\n                    ProcessError(response.error);\n                }\n            }\n              \n        }<\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-create-block-tab tab-panel\" role=\"tabpanel\" tabindex=\"0\">\n<p><strong>Address Detective Java Code Snippet<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">FoundAddressResponse ADResponse = null;\nADError error = null;\nFixedAddressResponse.FixedAddress[] addresses = null;\nString addr1 = request.getParameter(\"iAddr1\");\nString addr2 = request.getParameter(\"iAddr2\");\nString city = request.getParameter(\"iCity\");\nString state = request.getParameter(\"iState\");\nString postalCode = request.getParameter(\"iPostalCode\");\nString businessName = request.getParameter(\"iBusinessName\");\nString phoneNumber = request.getParameter(\"iPhoneNumber\");\nString fullName = request.getParameter(\"iFullName\");\nString firstName = request.getParameter(\"iFirstName\");\nString lastName = request.getParameter(\"iLastName\");\nString licenseKey = request.getParameter(\"iKey\");\n  \nADRestClient ADClient = new ADRestClient();\nFixedAddressResponse result = ADClient.FindAddress(addr1,addr2, city, state, postalCode, businessName, phoneNumber, fullName, firstName, lastName, licenseKey);\nif (result != null) {\nerror = result.error;\naddresses = result.Addresses;\n}\n   \n\/\/Process Results\nif (error == null) {\n    \/\/DOTS Address Detective Results\n          \n}\n   \n\/\/Process Errors\nelse{\n}\n    \/\/DOTS Address Detective Error\n      \n}<\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-create-block-tab tab-panel\" role=\"tabpanel\" tabindex=\"0\">\n<p><strong>Address Detective PHP Code Snippet<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n    $Address1 = trim($Address1);\n    $Address2 = trim($Address2);\n    $City = trim($City);\n    $State = trim($State);\n    $PostalCode = trim($PostalCode);\n    $BusinessName = trim($BusinessName);\n    $PhoneNumber = trim($PhoneNumber);\n    $FullName = trim($FullName);\n    $FirstName = trim($FirstName);\n    $LastName = trim($LastName);\n    $LicenseKey = trim($LicenseKey);\n   \n$TrialURL=\"https:\/\/trial.serviceobjects.com\/AD\/api.svc\/FindAddressJson\/\".rawurlencode($Address1).\"\/\".rawurlencode($Address2).\"\/\".rawurlencode($City).\"\/\".rawurlencode($State).\"\/\".rawurlencode($PostalCode).\"\/\".rawurlencode($BusinessName).\"\/\".rawurlencode($PhoneNumber).\"\/\".rawurlencode($FullName).\"\/\".rawurlencode($FirstName).\"\/\".rawurlencode($LastName).\"\/\".rawurlencode($LicenseKey);\n  \n        \/\/ Get cURL resource\n            $curl = curl_init();\n            curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $URL, CURLOPT_USERAGENT => 'Service Objects AddressDetective'));\n            curl_setopt($curl, CURLOPT_TIMEOUT, 50); \/\/timeout in seconds\n            \/\/ Send the request &amp; save response to $resp\n            $resp = curl_exec($curl);\n              \n            \/\/ Close request to clear up some resources\n            if($resp == false)\n            {\n                curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $backupURL, CURLOPT_USERAGENT => 'Service Objects Address Detective'));\n                curl_setopt($curl, CURLOPT_TIMEOUT, 50); \/\/timeout in seconds\n                \/\/ Send the request &amp; save response to $resp\n                $resp = curl_exec($curl);\n                if($resp == false)\n                {\n                    echo \"&lt;b> Both rest calls failed &lt;\/b>\";\n                    curl_close($curl);\n                    return;\n                }\n            }\n          \n        try\n        {\n            $jsonIterator = new RecursiveIteratorIterator(new RecursiveArrayIterator(json_decode($resp, TRUE)), RecursiveIteratorIterator::SELF_FIRST);\n        }\n        catch (Exception $e)\n        { \n            echo \"Invalid input.\";\n            $gotValidInput = false;\n        }\n        if($gotValidInput)\n        {\n            \/\/Process AD Results\n        }\n        else\n        {\n            \/\/Process AD Error\n        }\n?><\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-create-block-tab tab-panel\" role=\"tabpanel\" tabindex=\"0\">\n<p><strong>Address Detective RoR Code Snippet<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"ruby\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">class RequestsController &lt; ApplicationController\n  \n      address1 = @request.address1\n      address2 = @request.address2\n      city = @request.city\n      state = @request.state\n      postalcode = @request.postalcode\n      businessname = @request.businessname\n      phonenumber = @request.phonenumber\n      fullname = @request.fullname\n      firstname = @request.firstname\n      lastname = @request.lastname\n      licensekey = @request.licensekey\n        \n              \n      #Set Primary and Backup URLs as needed. This method encodes and standardizes the URI to pass to the REST service.\n      primaryURL = URI.encode(\"https:\/\/trial.serviceobjects.com\/ad\/api.svc\/FindAddress?\"+\"Address1=\" + address1 + \"&amp;Address2=\" + address2 + \"&amp;City=\" + city + \"&amp;State=\" + state + \"&amp;PostalCode=\" + postalcode + \"BusinessName=\" + businessname + \"&amp;PhoneNumber=\" + phonenumber + \"&amp;FullName=\" + fullname + \"&amp;FirstName=\" + firstname + \"&amp;LastName=\" + lastname + \"&amp;LicenseKey=\" + licensekey)\n      backupURL = URI.encode(\"https:\/\/trial.serviceobjects.com\/ad\/api.svc\/FindAddress?\"+\"Address1=\" + address1 + \"&amp;Address2=\" + address2 + \"&amp;City=\" + city + \"&amp;State=\" + state + \"&amp;PostalCode=\" + postalcode + \"BusinessName=\" + businessname + \"&amp;PhoneNumber=\" + phonenumber + \"&amp;FullName=\" + fullname + \"&amp;FirstName=\" + firstname + \"&amp;LastName=\" + lastname + \"&amp;LicenseKey=\" + licensekey)\n        \n        \n      #These are set to access the hash that is returned\n      @adresult =\"FixedAddressResponse\"\n      @adaddresses = \"Addresses\"\n      @adfixed = \"FixedAddress\"\n      @aderror = \"Error\"\n        #Begins the call the RESTful web service\n      begin\n        response = HTTParty.get(primaryURL, timeout: default_timeout)\n        #processes the response to display to the screen\n          \n        #Passes the response returned from HTTParty and processes them depending on the results\n        processresults(response)\n          \n       rescue StandardError => e\n            begin\n            #uses the backupURl in the event that the service encountered an error\n            response = HTTParty.get(backupURL, timeout: default_timeout)\n            \n          #processes the response returned from using the backupURL\n            processresults(response)\n          #If the backup url railed this will raise an error and display the\n          #error message returned from the HTTParty gem.\n            rescue StandardError => error\n                @status = error.message\n                @displaydata = {\"Error\" => \"An Error Occured\"}\n            end\n      end\n        \n  end\n    private\n    #processes HTTParty response a\n    def processresults(response)   \n          \n    end\n      \nend<\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-create-block-tab tab-panel\" role=\"tabpanel\" tabindex=\"0\">\n<p><strong>Address Detective Python Code Snippet<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mAddress1 = Address1.get()\nif mAddress1 is None or mAddress1 == \"\":\n    mAddress1 = \" \"\nmAddress2 = Address2.get()\nif mAddress2 is None or mAddress2 == \"\":\n    mAddress2 = \" \"\nmCity = City.get()\nif mCity is None or mCity == \"\":\n    mCity = \" \"\nmState = State.get()\nif mState is None or mState == \"\":\n    mState = \" \"\nmPostalCode = PostalCode.get()\nif mPostalCode is None or mPostalCode == \"\":\n    mPostalCode = \" \"\nmBusinessName = BusinessName.get()\nif mBusinessName is None or mBusinessName == \"\":\n    mBusinessName = \" \"\nmPhoneNumber = PhoneNumber.get()\nif mPhoneNumber is None or mPhoneNumber == \"\":\n    mPhoneNumber = \" \"\nmFullName = FullName.get()\nif mFullName is None or mFullName == \"\":\n    mFullName = \" \"\nmFirstName = FirstName.get()\nif mFirstName is None or mFirstName == \"\":\n    mFirstName = \" \"\nmLastName = LastName.get()\nif mLastName is None or mLastName == \"\":\n    mLastName = \" \"\nmLicenseKey = LicenseKey.get()\nif mLicenseKey is None or mLicenseKey == \"\":\n    mLicenseKey = \" \"\n#Set the primary and backup URLs as necessary\nprimaryURL = 'https:\/\/trial.serviceobjects.com\/ad\/api.svc\/FindAddress?'\nbackupURL = 'https:\/\/trial.serviceobjects.com\/ad\/api.svc\/FindAddress?'\n#The\n Requests package allows the user to format the path parameters like so\ninstead of having to manually insert them into the URL\ninputs = {'Address1': mAddress1, 'Address2': mAddress2, 'City': mCity, 'State': mState, \"PostalCode\": mPostalCode, 'BusinessName': mBusinessName, 'PhoneNumber': mPhoneNumber, 'FullName': mFullName, 'FirstName':mFirstName, 'LastName':mLastName, 'LicenseKey': mLicenseKey}\ntry:\n    result = requests.get(primaryURL, params=inputs)\n  \n    #Parses the XML response from the service into a python dictionary type\n    outputs = xmltodict.parse(result.content)\n  \n    #handle response and displays the info accordingly\n  \n#This tries the backup URL if the primary URL failed\nexcept:\n    try:\n        result = requests.get(backupURL, params=inputs)\n        #Parses the XML response from the service into a python dictionary type\n        outputs = xmltodict.parse(result.content)\n  \n        #handle response and displays the info accordingly\n         \n    #Prints an error message to screen if the primary and backup url failed\n    except:\n        Label(swin.window, text='Error').pack()\n        \n        print (result)<\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-create-block-tab tab-panel\" role=\"tabpanel\" tabindex=\"0\">\n<p><strong>Address Detective ColdFusion Code Snippet<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"xml\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;!--Makes Request to web service --->\n&lt;cfIf isDefined(\"form.Action\") AND Action neq \"\" >\n    &lt;cftry>\n        &lt;cfset primaryURL =  \"https:\/\/trial.serviceobjects.com\/ad\/api.svc\/FindAddress?Address1=#Address1#&amp;Address2=#Address2#&amp;City=#City#&amp;State=#State#&amp;PostalCode=#PostalCode#&amp;BusinessName=#BusinessName#&amp;PhoneNumber=#PhoneNumber#&amp;FullName=#FullName#&amp;FirstName=#FirstName#&amp;LastName=#LastName#&amp;LicenseKey=#LicenseKey#\">\n        &lt;cfhttp url=\"#primaryURL#\" method=\"get\" result=\"response\">\n        &lt;cfset outputs = XmlParse(response.FileContent)>\n        &lt;cfcatch>\n            &lt;cftry>\n                &lt;cfset backupURL =  \"https:\/\/trial.serviceobjects.com\/ad\/api.svc\/FindAddress?Address1=#Address1#&amp;Address2=#Address2#&amp;City=#City#&amp;State=#State#&amp;PostalCode=#PostalCode#&amp;BusinessName=#BusinessName#&amp;PhoneNumber=#PhoneNumber#&amp;FullName=#FullName#&amp;FirstName=#FirstName#&amp;LastName=#LastName#&amp;LicenseKey=#LicenseKey#\">\n                &lt;cfhttp url=\"#backupURL#\" method=\"get\" result=\"response\">\n                &lt;cfset outputs = XmlParse(response.FileContent)>             \n                &lt;cfcatch >\n                    &lt;cfoutput >\n                        The Following Error Occured: #response.StatusCode#\n                    &lt;\/cfoutput>\n                &lt;\/cfcatch>\n            &lt;\/cftry>\n        &lt;\/cfcatch>\n    &lt;\/cftry>\n&lt;\/cfif><\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-create-block-tab tab-panel\" role=\"tabpanel\" tabindex=\"0\">\n<p><strong>Address Detective VB Code Snippet<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"visualbasic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">'encodes the URLs for the get Call. Set the primary and back urls as necessary\nDim primaryurl As String = \"https:\/\/trial.serviceobjects.com\/ad\/api.svc\/FindAddress?\" + \"Address1=\" + address1 + \"&amp;Address2=\" + address2 + \"&amp;City=\" + city + \"&amp;State=\" + state + \"&amp;PostalCode=\" + postalcode + \"BusinessName=\" + businessname + \"&amp;PhoneNumber=\" + phonenumber + \"&amp;FullName=\" + fullname + \"&amp;FirstName=\" + firstname + \"&amp;LastName=\" + lastname + \"&amp;LicenseKey=\" + licensekey\nDim backupurl As String = \"https:\/\/trial.serviceobjects.com\/ad\/api.svc\/FindAddress?\" + \"Address1=\" + address1 + \"&amp;Address2=\" + address2 + \"&amp;City=\" + city + \"&amp;State=\" + state + \"&amp;PostalCode=\" + postalcode + \"BusinessName=\" + businessname + \"&amp;PhoneNumber=\" + phonenumber + \"&amp;FullName=\" + fullname + \"&amp;FirstName=\" + firstname + \"&amp;LastName=\" + lastname + \"&amp;LicenseKey=\" + licensekey\n  \nDim wsresponse As ADResponse.FixedAddressResponse = httpGet(primaryurl)\n  \n  \n'checks if a response was returned from the service, uses the backup url if response is null or a fatal error occured.\nIf wsresponse Is Nothing OrElse (wsresponse.[Error] IsNot Nothing AndAlso wsresponse.[Error].TypeCode = \"3\") Then\n  \n    wsresponse = httpGet(backupurl)\nEnd If\n  \nIf wsresponse.[Error] IsNot Nothing Then\n    ProcessErrorResponse(wsresponse.[Error])\nElse\n    ProcessSuccessfulResponse(wsresponse)\nEnd If<\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-create-block-tab tab-panel\" role=\"tabpanel\" tabindex=\"0\">\n<p><strong>Address Detective TSQL Code Snippet<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"sql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">BEGIN\n    SET @sUrl = 'https:\/\/trial.serviceobjects.com\/ad\/api.svc\/FindAddress?Address1=' + @address1 + '&amp;Address2=' + @address2 + '&amp;City=' + @city + '&amp;State=' + @state + '&amp;PostalCode=' + @postalcode + '&amp;BusinessName=' + @businessname + '&amp;PhoneNumber=' + @phonenumber + '&amp;FullName=' + @fullname + '&amp;FirstName=' + @firstname + '&amp;LastName=' + @lastname + '&amp;LicenseKey=' + @key\n    EXEC sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT\n    EXEC sp_OAMethod @obj, 'Open', NULL, 'Get', @sUrl, false\n    EXEC sp_OAMethod @obj, 'send'\n    EXEC sp_OAGetProperty @obj, 'responseText', @response OUT\n              \n    --Checks the Response for a fatal error or if null.\n    IF @response IS NULL\n    BEGIN\n        SET @sBackupUrl = 'https:\/\/trial.serviceobjects.com\/ad\/api.svc\/FindAddress?Address1=' + @address1 + '&amp;Address2=' + @address2 + '&amp;City=' + @city + '&amp;State=' + @state + '&amp;PostalCode=' + @postalcode + '&amp;BusinessName=' + @businessname + '&amp;PhoneNumber=' + @phonenumber + '&amp;FullName=' + @fullname + '&amp;FirstName=' + @firstname + '&amp;LastName=' + @lastname + '&amp;LicenseKey=' + @key\n        EXEC sp_OACreate 'MSXML2.ServerXMLHttp', @obj OUT\n        EXEC sp_OAMethod @obj, 'Open', NULL, 'Get', @sBackupUrl, false\n        EXEC sp_OAMethod @obj, 'send'\n        EXEC sp_OAGetProperty @obj, 'responseText', @response OUT\n    END\nEND<\/pre>\n<\/div>\n\n\n\n<div class=\"wp-block-create-block-tab tab-panel\" role=\"tabpanel\" tabindex=\"0\">\n<p><strong>Address Detective NodeJS Code Snippet<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/Set backup and primary URL as necessary\nvar primaryUrl = 'https:\/\/trial.serviceobjects.com\/ad\/api.svc\/FindAddress?Address1='+ Address1+'&amp;Address2='+ Address2 + '&amp;City=' + City +'&amp;State=' + State +'&amp;PostalCode=' + PostalCode + '&amp;BusinessName=' + BusinessName + '&amp;PhoneNumber=' + PhoneNumber + '&amp;FullName=' + FullName + '&amp;FirstName=' + FirstName + '&amp;LastName=' + LastName +'&amp;LicenseKey=' + LicenseKey;\nvar backupUrl = 'https:\/\/trial.serviceobjects.com\/ad\/api.svc\/FindAddress?Address1='+ Address1+'&amp;Address2='+ Address2 + '&amp;City=' + City +'&amp;State=' + State +'&amp;PostalCode=' + PostalCode + '&amp;BusinessName=' + BusinessName + '&amp;PhoneNumber=' + PhoneNumber + '&amp;FullName=' + FullName + '&amp;FirstName=' + FirstName + '&amp;LastName=' + LastName +'&amp;LicenseKey=' + LicenseKey;\n  \n  \nvar req = http.get(primaryUrl, function(res) {\n  \nres.setEncoding('utf8');\nres.on('data', function (results) {\n  \n    var parser = require('xml2js').Parser({explicitArray: false,ignoreAttrs: true});\n    parser.parseString(results, function (err, outputs) {\n        if (outputs.FixedAddressResponse.Error !=  null)\n        {\n            \/\/Indicates a Fatal error has occured. If this happens, the logic will then failover to the backup url\n            if (outputs.FixedAddressResponse.Error.TypeCode == \"3\")\n            {\n                var backupReq = http.get(backupUrl, function(backupRes) {\n                    backupRes.setEncoding('utf8');\n                    backupRes.on('data', function (results) {\n  \n                            var parser = require('xml2js').Parser({explicitArray: false,ignoreAttrs: true});\n                            parser.parseString(results, function (err, outputs) {\n  \n                                console.log(\"Backup Call Was Used.\");\n                                response.end(JSON.stringify(outputs , null, 3));\n                            });\n                        });\n                    });\n            }\n            else\n            {\n                \/\/Will Display the JSON Formatted Error Response here\n                response.end(JSON.stringify(outputs, null, 3));\n                return;\n            }\n        }\n        else\n        {\n            \/\/Will Display the JSON Formatted Valid Response here\n            response.end(JSON.stringify(outputs, null, 3));\n            return;\n        }\n    });\n});<\/pre>\n<\/div>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":1622,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1633","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>AD - REST<\/title>\n<meta name=\"description\" content=\"C#JavaPHPRoRPythonColdFusionVBTSQLNodeJS Address Detective C# Code Snippet string mainURL = TrialURL+ address1 + &quot;\/&quot; + address2 + &quot;\/&quot; + city + &quot;\/&quot; + state\" \/>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"AD - REST\" \/>\n<meta property=\"og:description\" content=\"C#JavaPHPRoRPythonColdFusionVBTSQLNodeJS Address Detective C# Code Snippet string mainURL = TrialURL+ address1 + &quot;\/&quot; + address2 + &quot;\/&quot; + city + &quot;\/&quot; + state\" \/>\n<meta property=\"og:url\" content=\"https:\/\/test.serviceobjects.com\/docs\/dots-address-detective\/ad-code-snippets-and-sample-code\/ad-rest\/\" \/>\n<meta property=\"og:site_name\" content=\"Service Objects | Contact, Phone, Email Verification | Data Quality Services\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-29T21:12:56+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/test.serviceobjects.com\/docs\/dots-address-detective\/ad-code-snippets-and-sample-code\/ad-rest\/\",\"url\":\"https:\/\/test.serviceobjects.com\/docs\/dots-address-detective\/ad-code-snippets-and-sample-code\/ad-rest\/\",\"name\":\"AD - REST\",\"isPartOf\":{\"@id\":\"https:\/\/test.serviceobjects.com\/docs\/#website\"},\"datePublished\":\"2022-11-05T11:33:05+00:00\",\"dateModified\":\"2024-03-29T21:12:56+00:00\",\"description\":\"C#JavaPHPRoRPythonColdFusionVBTSQLNodeJS Address Detective C# Code Snippet string mainURL = TrialURL+ address1 + \\\"\/\\\" + address2 + \\\"\/\\\" + city + \\\"\/\\\" + state\",\"breadcrumb\":{\"@id\":\"https:\/\/test.serviceobjects.com\/docs\/dots-address-detective\/ad-code-snippets-and-sample-code\/ad-rest\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/test.serviceobjects.com\/docs\/dots-address-detective\/ad-code-snippets-and-sample-code\/ad-rest\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/test.serviceobjects.com\/docs\/dots-address-detective\/ad-code-snippets-and-sample-code\/ad-rest\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/test.serviceobjects.com\/docs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"DOTS Address Detective\",\"item\":\"https:\/\/test.serviceobjects.com\/docs\/dots-address-detective\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"AD &#8211; Code Snippets and Sample Code\",\"item\":\"https:\/\/test.serviceobjects.com\/docs\/dots-address-detective\/ad-code-snippets-and-sample-code\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"AD &#8211; REST\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/test.serviceobjects.com\/docs\/#website\",\"url\":\"https:\/\/test.serviceobjects.com\/docs\/\",\"name\":\"Service Objects | Contact, Phone, Email Verification | Data Quality Services\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/test.serviceobjects.com\/docs\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/test.serviceobjects.com\/docs\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/test.serviceobjects.com\/docs\/#organization\",\"name\":\"Service Objects | Contact, Phone, Email Verification | Data Quality Services\",\"url\":\"https:\/\/test.serviceobjects.com\/docs\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/test.serviceobjects.com\/docs\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/test.serviceobjects.com\/docs\/wp-content\/uploads\/2022\/08\/SO-logo-2560px-transparent.png\",\"contentUrl\":\"https:\/\/test.serviceobjects.com\/docs\/wp-content\/uploads\/2022\/08\/SO-logo-2560px-transparent.png\",\"width\":2560,\"height\":1440,\"caption\":\"Service Objects | Contact, Phone, Email Verification | Data Quality Services\"},\"image\":{\"@id\":\"https:\/\/test.serviceobjects.com\/docs\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"AD - REST","description":"C#JavaPHPRoRPythonColdFusionVBTSQLNodeJS Address Detective C# Code Snippet string mainURL = TrialURL+ address1 + \"\/\" + address2 + \"\/\" + city + \"\/\" + state","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"AD - REST","og_description":"C#JavaPHPRoRPythonColdFusionVBTSQLNodeJS Address Detective C# Code Snippet string mainURL = TrialURL+ address1 + \"\/\" + address2 + \"\/\" + city + \"\/\" + state","og_url":"https:\/\/test.serviceobjects.com\/docs\/dots-address-detective\/ad-code-snippets-and-sample-code\/ad-rest\/","og_site_name":"Service Objects | Contact, Phone, Email Verification | Data Quality Services","article_modified_time":"2024-03-29T21:12:56+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/test.serviceobjects.com\/docs\/dots-address-detective\/ad-code-snippets-and-sample-code\/ad-rest\/","url":"https:\/\/test.serviceobjects.com\/docs\/dots-address-detective\/ad-code-snippets-and-sample-code\/ad-rest\/","name":"AD - REST","isPartOf":{"@id":"https:\/\/test.serviceobjects.com\/docs\/#website"},"datePublished":"2022-11-05T11:33:05+00:00","dateModified":"2024-03-29T21:12:56+00:00","description":"C#JavaPHPRoRPythonColdFusionVBTSQLNodeJS Address Detective C# Code Snippet string mainURL = TrialURL+ address1 + \"\/\" + address2 + \"\/\" + city + \"\/\" + state","breadcrumb":{"@id":"https:\/\/test.serviceobjects.com\/docs\/dots-address-detective\/ad-code-snippets-and-sample-code\/ad-rest\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/test.serviceobjects.com\/docs\/dots-address-detective\/ad-code-snippets-and-sample-code\/ad-rest\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/test.serviceobjects.com\/docs\/dots-address-detective\/ad-code-snippets-and-sample-code\/ad-rest\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/test.serviceobjects.com\/docs\/"},{"@type":"ListItem","position":2,"name":"DOTS Address Detective","item":"https:\/\/test.serviceobjects.com\/docs\/dots-address-detective\/"},{"@type":"ListItem","position":3,"name":"AD &#8211; Code Snippets and Sample Code","item":"https:\/\/test.serviceobjects.com\/docs\/dots-address-detective\/ad-code-snippets-and-sample-code\/"},{"@type":"ListItem","position":4,"name":"AD &#8211; REST"}]},{"@type":"WebSite","@id":"https:\/\/test.serviceobjects.com\/docs\/#website","url":"https:\/\/test.serviceobjects.com\/docs\/","name":"Service Objects | Contact, Phone, Email Verification | Data Quality Services","description":"","publisher":{"@id":"https:\/\/test.serviceobjects.com\/docs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/test.serviceobjects.com\/docs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/test.serviceobjects.com\/docs\/#organization","name":"Service Objects | Contact, Phone, Email Verification | Data Quality Services","url":"https:\/\/test.serviceobjects.com\/docs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/test.serviceobjects.com\/docs\/#\/schema\/logo\/image\/","url":"https:\/\/test.serviceobjects.com\/docs\/wp-content\/uploads\/2022\/08\/SO-logo-2560px-transparent.png","contentUrl":"https:\/\/test.serviceobjects.com\/docs\/wp-content\/uploads\/2022\/08\/SO-logo-2560px-transparent.png","width":2560,"height":1440,"caption":"Service Objects | Contact, Phone, Email Verification | Data Quality Services"},"image":{"@id":"https:\/\/test.serviceobjects.com\/docs\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/test.serviceobjects.com\/docs\/wp-json\/wp\/v2\/pages\/1633","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/test.serviceobjects.com\/docs\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/test.serviceobjects.com\/docs\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/test.serviceobjects.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/test.serviceobjects.com\/docs\/wp-json\/wp\/v2\/comments?post=1633"}],"version-history":[{"count":13,"href":"https:\/\/test.serviceobjects.com\/docs\/wp-json\/wp\/v2\/pages\/1633\/revisions"}],"predecessor-version":[{"id":10066,"href":"https:\/\/test.serviceobjects.com\/docs\/wp-json\/wp\/v2\/pages\/1633\/revisions\/10066"}],"up":[{"embeddable":true,"href":"https:\/\/test.serviceobjects.com\/docs\/wp-json\/wp\/v2\/pages\/1622"}],"wp:attachment":[{"href":"https:\/\/test.serviceobjects.com\/docs\/wp-json\/wp\/v2\/media?parent=1633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}