USPS Lookup City and State by Zip Code Data Flow Template

Screenshot_1.png

Overview

This Data Flow template is made up of six Data Operations that allow app builders to find the city and state of a given zip code by passing data through this Data Flow.

In Connection Builder, Data Flow templates can be found with pre-populated sample data. However, to meet the requirements of their Journey, app builders should perform the necessary adjustments, such as adding other Data Ops.

Data Operations

This Data Flow contains eight parts:

Inputs

The Start pane keeps track of the inputs required by the Data Flow. 

  • Transform Expression: Airscript expression to format the XML payload for the HTTP Request.
  • Output Format: Variable
  • Type: Text
  • Run Results: payload output Variable of type Text that is automatically created to hold the result of this Operation.

  • Service: no service selected
  • Method: GET - to retrieve data
  • URL: USPS Shipping API endpoint
  • Allow non-compliant HTTP headers: box unchecked
  • Content-Type: “txt/xml”
  • Headers: no parameter set
  • Query Parameters: HTTP Parameter 
    • Field Name: API
    • Value: CityStateLookup
    • Field Name: MXL
    • Value: Payload
  • Form Parameters: no parameter set
  • Had paging?: box unchecked
  • Run Results: AirData Variables of type Any that automatically created to hold the results of this Operation. 
    • result
    • rawResult
    • request

  • Transform Expression: rawResult.Body - Airscript expression to get the result of the HTTP request as an XML output.
  • Output Format: Variable
  • Type: Text
  • Run Results: xml_output Variable of type Text that is automatically created to hold the result of this Operation.

  • Input Value (String): xml_output - Airscript expression to convert a Text value with XML into JSON.
  • Run Results: json_output Variable of type Any that is automatically created to hold the result of this Operation.

Transform Data Operation

  • Transform Expression: Airscript expression to parse through the JSON.
  • Output Format: Variable
  • Type: Any
  • Run Results: zip_output Variable of type Any that is automatically created to hold the result of this Operation.

Transform Data Operation

  • Transform Expression: Airscript expression to format the output to pass as an output of the data flow.
  • Output Format: Variable
  • Type: Any
  • Run Results: output Variable of type Any that is automatically created to hold the result of this Operation.

Output

The End step is where variables from the Data Flow can be used as an output..

  • output Return Value of type Any

Use Cases

  • Allow app builders to call the corresponding city and state of a given zip code using the USPS API of shipping and mailing services.