Skip to main content

Encode Parameters to Avoid Custom Action Errors

Most custom actions rely on API requests to a third-party application, which generally requires passing in various parameters to find the data you're looking for or to perform a specific process. When using values that are user-generated or otherwise dynamic, you run the risk of passing in special characters that aren't supported, potentially resulting in a server error.

For example, you might have a custom action to retrieve customer data using their email address as the unique identifier. If this email address contains a special character, like a plus, "+", that character may be interpreted by the server as a space and cause unexpected behavior.

To avoid this, we recommend that you encode any paramters that might contain special characters using the Encode URL formula in your custom action request:

  1. Navigate to the data source and, in the data source configuration panel, select Actions. The Action screen displays.

  2. Select the relevant custom action. The General screen displays.

    custom_action_select.png
  3. Select Request. The Request screen displays.

    custom_action_request_select.png
  4. In the Path field, remove the action param you want to encode.

    custom_action_remove_param.png
  5. With the cursor in the correct location to insert the param in the Path field, select the insert field button, insert_field.png, then select the Formula Fields button, formula_calculator.png. The formula field dropdown displays.

    custom_action_formula_fields.png
  6. In the search field, enter "Encode" and select Encode URL. The Create formula window displays.

    custom_action_select_encode_formula.png
  7. In the Formula Editor, select Field. The Field dropdown displays.

    create_formula_field_select.png
  8. Select the Insert Param button, formula_preset.png, then select the action param, Customer Email.

    create_formula_params_customer_email.png
  9. When finished, select Done. The Create formula window closes.

    create_formula_done.png

    The Request screen displays, including your newly-updated endpoint path:

    custom_action_updated_endpoint.png

    Now, the Encode URL formula automatically encodes the paramater to ensure only valid characters are passed in to the application's API. Follow this same process for any other params that you might use as part of an API request or in a URL in general.