GetPostalCodes allows you to look up the postal codes for a particular city. The service takes a city, state, and country as input and returns the postal codes for that city. The input must be exactly correct in order to return postal codes.
Note: GetPostalCodes only works with U.S. addresses.
GetPostalCodes is part of the Spectrum Universal Address.
Resource URL
JSON endpoint:
http://server:port/rest/GetPostalCodes/results.json
https://OnDemandServer/rest/GetPostalCodes/results.json
XML endpoint:
http://server:port/rest/GetPostalCodes/results.xml
https://OnDemandServer/rest/GetPostalCodes/results.xml
For a list of Spectrum OnDemand servers, see Connecting to Spectrum OnDemand Servers.
Example with JSON Response
The following example requests a JSON response:
http://myserver:8080/rest/GetPostalCodes/results.json?Data.City=Holland&Data.StateProvince=MI
https://spectrum.precisely.com/rest/GetPostalCodes/results.json?Data.City=Holland&Data.StateProvince=MI
The JSON returned by this request would be:
{"output_port": [
{
"ProcessedBy": "USA",
"PostalCode": "49422",
"Status": "",
"City.Type": " ",
"Status.Code": "",
"Status.Description": "",
"user_fields": []
},
{
"ProcessedBy": "USA",
"PostalCode": "49423",
"Status": "",
"City.Type": " ",
"Status.Code": "",
"Status.Description": "",
"user_fields": []
},
{
"ProcessedBy": "USA",
"PostalCode": "49424",
"Status": "",
"City.Type": " ",
"Status.Code": "",
"Status.Description": "",
"user_fields": []
}
]}
Example with XML Response
The following example requests an XML response:
http://myserver:8080/rest/GetPostalCodes/results.xml?Data.City=Holland&Data.StateProvince=MI
https://spectrum.precisely.com/rest/GetPostalCodes/results.xml?Data.City=Holland&Data.StateProvince=MI
The XML returned by this request would be:
<ns2:xml.GetPostalCodesResponse
xmlns:ns2="http://www.pb.com/spectrum/services/GetPostalCodes">
<ns2:output_port>
<ns2:Result>
<ns2:ProcessedBy>USA</ns2:ProcessedBy>
<ns2:PostalCode>49422</ns2:PostalCode>
<ns2:City.Type></ns2:City.Type>
<ns2:Status/>
<ns2:Status.Code/>
<ns2:Status.Description/>
<ns2:user_fields/>
</ns2:Result>
<ns2:Result>
<ns2:ProcessedBy>USA</ns2:ProcessedBy>
<ns2:PostalCode>49423</ns2:PostalCode>
<ns2:City.Type></ns2:City.Type>
<ns2:Status/>
<ns2:Status.Code/>
<ns2:Status.Description/>
<ns2:user_fields/>
</ns2:Result>
<ns2:Result>
<ns2:ProcessedBy>USA</ns2:ProcessedBy>
<ns2:PostalCode>49424</ns2:PostalCode>
<ns2:City.Type></ns2:City.Type>
<ns2:Status/>
<ns2:Status.Code/>
<ns2:Status.Description/>
<ns2:user_fields/>
</ns2:Result>
</ns2:output_port>
</ns2:xml.GetPostalCodesResponse>