---
title: URL Parsing
date: 2025-12-30T05:34:57Z
modified: 2026-06-12T09:03:37Z
permalink: "https://ezintegrations.ai/docs/parse-and-modify-urls-json/"
type: docs
status: publish
excerpt: ""
wpid: 3072
doc_category:
  - Pycode Examples
author: Arun Thakur
---

## Overview

URL parsing is used to transform and encode URL strings into a standardized format suitable for transmission, storage, and integration workflows.

In eZintegrations, Python Operations can be used to encode special characters in URL paths to ensure compatibility with APIs and external systems.

---

## When to Use

Use this method when incoming URLs contain special characters or path separators that must be encoded for safe processing.

- Preparing URLs for API requests
- Encoding dynamic URL parameters
- Ensuring compatibility with external systems
- Preventing URL parsing errors
- Standardizing URL formats

---

## How It Works

The Python script retrieves the URL value from the **name** key and encodes it using the **quote()** function from the urllib.parse module.

This function replaces special characters such as slashes (/) with their URL-encoded equivalents, ensuring safe transmission.

---

## Input Example

In the current context, the URL is received in the **name** key in the following format.

📋

{
  "name": "{{base_url}}abc/xyz/pqr"
}


---

## Python Operation Logic

The following Python script encodes the URL path and updates the existing data using the pycode\_data variable.

📋

from urllib.parse import quote

Responsedata = []

keyname_1 = ["name"]

for i in keyname_1:
    name = pycode_data.pop(i, None)
    encoded_object_name = quote(name, safe="")
    pycode_data["name"] = encoded_object_name


---

## Output Example

After applying URL encoding, the original path separators are converted into encoded characters.

📋

{
  "name": "{{base_url}}abc%2Fxyz%2Fpqr"
}


---

## How to Use

Follow these steps to parse and encode URLs using Python Operations.

1. Configure the integration to receive URL values in the name key.
2. Open the Python Operation editor.
3. Paste the URL parsing script.
4. Verify that pycode\_data contains the name field.
5. Save and deploy the workflow.
6. Test the operation with sample URLs.

---

## Use Case Example

This method is useful when working with dynamic object names or file paths in API requests.

- Input: {{base\_url}}reports/2026/january
- Output: {{base\_url}}reports%2F2026%2Fjanuary
- Usage: Secure API endpoint calls

---

## Troubleshooting

- Ensure the name key exists in the input data.
- Verify that the value is not null or empty.
- Check for unsupported characters in URLs.
- Confirm that urllib.parse is available in the execution environment.
- Review logs if encoding fails.

---

## Frequently Asked Questions

 ### 1. What does the quote() function do?

 The quote() function converts special characters in a URL string into URL-encoded format.

 

 

  ### 2. Why is safe set to an empty string?

 Setting safe to an empty string ensures that all special characters are encoded.

 

 

  ### 3. Does this affect the base URL?

 Only the value assigned to the name key is encoded. The base URL reference remains unchanged.

 

 

  ### 4. Can I exclude certain characters from encoding?

 Yes. You can specify allowed characters in the safe parameter of the quote() function.

 

 

  ### 5. Is URL encoding required for all integrations?

 No. It is required only when external systems expect encoded URL formats.

 

 

 ---

## Notes

- Always validate URLs before encoding.
- Use consistent encoding practices across workflows.
- Avoid double-encoding already encoded URLs.
- Test URL handling with multiple input formats.

## Topics

**Docs Categories:** [Pycode Examples](https://ezintegrations.ai/wp-content/uploads/wp-mfa-exports/taxonomy/doc_category/pycode-examples.md)