Page 1 of 1

Accessing Subfolders with spaces via REST API

Posted: Sat Aug 19, 2017 8:39 pm
by seth.stenzel
Hello all,

I'm relatively new to working with the REST API back end and documentation does not seem to cover my issue. I am trying to figure out what uri I would use to access and item that has a space in it.

I have a sub folder in my inbox call "test", and a second folder called "test 1"

I can access the inbox and get data, or the test folder with the two calls respectively:

Code: Select all


However I cannot find what syntax need to be use when a sub folder contains a space in the name. I have tried '_', '+' and "%20" and all return that the object does not exist.


Code: Select all


All of the above will fail.

Any assistance would be greatly appreciated. Everything else is working save for that and its going to look silly to tell my boss, "We can run stats that inbox we just can't have a sub folder with a space in the name. :lol:

Thank you all!

~Seth S.

Re: Accessing Subfolders with spaces via REST API

Posted: Fri Aug 25, 2017 12:17 am
by tmclane
Hello Seth,

May I ask which version you are running your tests against?
Perhaps your shell is removing or otherwise messing with your URL before it is sent to the server.
You can see exactly what the server sees by looking in the /opt/zimbra/log/access_log.<today's date>


Code: Select all - - [25/Aug/2017:00:20:45 +0000] "GET HTTP/1.1" 200 269 "-" "Jakarta Commons-HttpClient/3.1" 10

Test Scenario

    Setup account on mailbox / <password>
    Login through webclient and create a folder inside the Inbox named Spaced Folder
    Send a few emails to your own account
    Move at least one email in to Spaced Folder

Request items in Spaced Folder using curl:

Note: The double quotes are to prevent the shell (in my case bash) from mangling the URL.
The %20 encoding for a space character works in my case.

Code: Select all

curl -k -u<password> "" | python -mjson.tool

Code: Select all

    "m": [
            "cid": "260",
            "d": 1503600676000,
            "e": [
                    "a": "",
                    "d": "user",
                    "p": "user",
                    "t": "t"
                    "a": "",
                    "d": "user",
                    "t": "f"
            "fr": "How are you doing? Are you ready for Hurricane Harvey? -travis",
            "id": "259",
            "l": "261",
            "rev": 7,
            "s": 2415,
            "su": "This is a message"

Re: Accessing Subfolders with spaces via REST API

Posted: Wed Sep 13, 2017 4:07 pm
by seth.stenzel
So what I found out is that this "&query=is:unread" is the difference between success and failure for me.

My zimbra version is: Zimbra 8.6.0_GA_1200 (build 20160606111426)

So basically if I try and query unread objects inside a folder with a space in the name, it fails. If it does not have a space it works.
Now I can query the folder without the query option, and then just parse the json response, which is what I ended up doing.

Maybe someone else could try and verify the error and it could be reported as a bug.

Re: Accessing Subfolders with spaces via REST API

Posted: Wed Sep 13, 2017 5:32 pm
by tmclane
Would you please check and see what Nginx sees as the URL when you make a failing request?

Re: Accessing Subfolders with spaces via REST API

Posted: Wed Sep 13, 2017 8:23 pm
by seth.stenzel
Unfortunately as I have a working work around I'm not going to spend further time on the matter, if it is just me and my / our env that is fine. I'm not Ops and I don't have access to the host server/s. I'm just an emp tasked with putting together an email web monitoring dashboard and needed the rest API to work :P. Manually parsing the json response on the folder for the 'u' flag of an unread email is trivial and is fine for me. Maybe if someone else has this issue later they can do as you mention and see if they get the same result.

Thank you for your responses and suggestions however I appreciate it.

Re: Accessing Subfolders with spaces via REST API

Posted: Wed Sep 13, 2017 8:26 pm
by tmclane
Ok. Glad you found something that worked for you!

Re: Accessing Subfolders with spaces via REST API

Posted: Thu Apr 30, 2020 4:21 pm
by ronhill
I know this is an older thread, but I found it when trying to access 'Contacts' folders which contain spaces using the REST API and the 'query' keyword option. I have confirmed that a folder without spaces will correctly honor the 'query' keyword, but a folder with spaces will not. Browser responds as

Problem accessing /service/home/ronaldh/contacts/SD%20Employees. Reason:
no such item

It does honor the 'fmt' keyword when the folder name contains spaces.

Following is as recorded in the access log ...

Code: Select all

[30/Apr/2020:15:35:37 +0000] "GET https://localhost:7070/service/home/myaccount/contacts/Testing?query=Hill HTTP/1.0" 200 821 "-" "Mozilla/5.0" 172

[30/Apr/2020:15:36:08 +0000] "GET https://localhost:7070/service/home/myaccount/contacts/Test%20Employees?query=Hill HTTP/1.0" 404 282 "-" "Mozilla/5.0" 3

[30/Apr/2020:15:36:46 +0000] "GET https://localhost:7070/service/home/myaccount/contacts/Test%20Employees?fmt=json HTTP/1.0" 200 2047 "-" "Mozilla/5.0" 5

Version: 8.8.10_GA_3801.FOSS

Any assistance would be appreciated.
Thank you!