# URL encoding in Ignition

**URL:** <https://forum.inductiveautomation.com/t/url-encoding-in-ignition/103562>\
**Category:** Ignition\
**Tags:** scripting, perspective\
**Created:** [March 12, 2025, 8:06am UTC](https://forum.inductiveautomation.com/t/url-encoding-in-ignition/103562 "2025-03-12T08:06:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ajay\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Ajay\_Gupta](https://forum.inductiveautomation.com/u/Ajay_Gupta)\
**Post date:** [March 12, 2025, 8:06am UTC](https://forum.inductiveautomation.com/t/url-encoding-in-ignition/103562/1 "2025-03-12T08:06:04Z")

</div>

Hi everyone,

I have a webdev mounted folder which has pdf files.  
I access these files through URL.  
One of the files has name "test - (Copy).pdf".

When I generate the URL and try to open it, I get the error "HTTP error 404 not found".  
I tried encoding the url using urllib with percent-encoding but still getting the same error.

2 encoded names that I tried:

- test%20-%20(Copy).pdf
- test%20-%20%28Copy%29.pdf

What am I doing wrong?  
How can I solve this issue?  
What is the best method to encode for any special characters?

I'll really appreciate any advice in this matter.  
A sample code would be the best.

Thanks,  
Ajay

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 12, 2025, 11:27am UTC](https://forum.inductiveautomation.com/t/url-encoding-in-ignition/103562/5 "2025-03-12T11:27:15Z")

</div>

Use [java.net.URLEncoder](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/net/URLEncoder.html)

---

<div class="post-metadata">

**Author:** ![Ajay\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Ajay\_Gupta](https://forum.inductiveautomation.com/u/Ajay_Gupta)\
**Post date:** [March 12, 2025, 11:52am UTC](https://forum.inductiveautomation.com/t/url-encoding-in-ignition/103562/6 "2025-03-12T11:52:13Z")

</div>

Thanks for your suggestion.

Do you have a sample code for this?

Below is the code that I am using which gives me "test+-+%28Copy%29.pdf" at the end.  
The generate URL does not work.

I still get the same 404 error.

Is there any limitation on the special characters that I should consider?  
Appreciate your help in this.

```python
from java.net import URLEncoder
from java.nio.charset import StandardCharsets

def encode_url():
    try:
        url = "https://ServerAddress:443/system/webdev/ProjectName/FileSystem/NetworkDrives/MyFolder/test - (Copy).pdf"
        
        # Encode only the path component that needs encoding
        base_url = "https://ServerAddress:443/system/webdev/ProjectName/FileSystem/NetworkDrives/MyFolder/"
        file_name = "test - (Copy).pdf"
        
        # Use URLEncoder to encode the file name
        encoded_file_name = URLEncoder.encode(file_name, StandardCharsets.UTF_8.toString())
        
        # Form the complete encoded URL
        encoded_url = base_url + encoded_file_name
        
        print("Encoded URL:", encoded_url)
        return encoded_url
    except Exception as e:
        # Print any exceptions that occur
        print("An error occurred:", e)

# Call the function to encode the URL
encoded_url = encode_url()

print encoded_url

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 12, 2025, 12:35pm UTC](https://forum.inductiveautomation.com/t/url-encoding-in-ignition/103562/7 "2025-03-12T12:35:22Z")

</div>

That looks about right. Look in your gateway logs for possible error messages.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 12, 2025, 12:46pm UTC](https://forum.inductiveautomation.com/t/url-encoding-in-ignition/103562/8 "2025-03-12T12:46:07Z")

</div>

This looks like a bug in the WebDev module to me. You shouldn't even have to manually URL-encode anything, your browser will do that before it sends the request anyway.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [March 12, 2025, 1:13pm UTC](https://forum.inductiveautomation.com/t/url-encoding-in-ignition/103562/9 "2025-03-12T13:13:16Z")

</div>

And your code works on a basic named file?

---

<div class="post-metadata">

**Author:** ![Ajay\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Ajay\_Gupta](https://forum.inductiveautomation.com/u/Ajay_Gupta)\
**Post date:** [March 12, 2025, 1:59pm UTC](https://forum.inductiveautomation.com/t/url-encoding-in-ignition/103562/10 "2025-03-12T13:59:40Z")

</div>

Yes, it works with basic named files.

---

<div class="post-metadata">

**Author:** ![Ajay\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Ajay\_Gupta](https://forum.inductiveautomation.com/u/Ajay_Gupta)\
**Post date:** [March 12, 2025, 2:04pm UTC](https://forum.inductiveautomation.com/t/url-encoding-in-ignition/103562/11 "2025-03-12T14:04:24Z")

</div>

I don't encode usually but since it was not working, I started exploring options. URL encoding is something that came to my mind first.  
Even that is not helping.

I got to know from one of my colleagues that special characters in names poses this problem in Ignition when it comes to generating URLs.  
I want to explore my options before I go to removing the special characters (like "()") from the filename, host the file to some other location with new name and get the URL from there.

If there is a way, please let me know.

I appreciate your response in this regard.

> [@URL encoding in Ignition](https://forum.inductiveautomation.com/t/url-encoding-in-ignition/103562/7):
>
> That looks about right. Look in your gateway logs for possible error messages.

@pturmel I don't get any error neither in browser console nor in Gateway log.

Thanks,  
Ajay

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 12, 2025, 2:06pm UTC](https://forum.inductiveautomation.com/t/url-encoding-in-ignition/103562/12 "2025-03-12T14:06:05Z")

</div>

I think it's broken. Open a support ticket and report a bug.
