Passing JSON arrays to the SOAP webservices - possible bug?

Have a great idea for extending Zimbra? Share ideas, ask questions, contribute, and get feedback.
Post Reply
leading zero
Posts: 35
Joined: Fri Apr 21, 2023 9:37 am
Location: Germany
ZCS/ZD Version: 10.0.3

Passing JSON arrays to the SOAP webservices - possible bug?

Post by leading zero »

Hi everyone,

when trying to pass arrays/lists of elements to the (admin) webservice as JSON, I noticed that only one of the elements actually makes it through the parsing stage in the webservice. When passing the request as XML however, everything works fine.
Is this a known issue? And is that maybe why the admin GUI gladly takes JSON responses, but sends XML requests to the webservice? :D

Example with AdminCreateWaitSet:

Code: Select all

{
    "Header": {
        "context": { .... }
    },
    "Body": {
        "AdminCreateWaitSetRequest": {
            "_jsns": "urn:zimbraAdmin",
            "add": [
                {
                    "a": {
                        "folderInterests": "2",
                        "name": "test_a@myzimbra",
                        "types": "all"
                    }
                },
                {
                    "a": {
                        "folderInterests": "2,5",
                        "name": "test_b@myzimbra",
                        "types": "all"
                    }
                }
            ]
        }
    }
}
In this example, only the second AdminCreateWaitSetRequest->add->a element is applied. I can see that by tracing through the ZCS source code while debugging remotely; and the WaitSet's behavior confirms that.

Another one, GetLoggerStats:

Code: Select all

{
    "Header": {
        "context": { .... }
        }
    },
    "Body": {
        "GetLoggerStatsRequest": [
            {
                "_jsns": "urn:zimbraAdmin",
                "endTime": {
                    "time": "1692366330"
                },
                "startTime": {
                    "time": "1692366180"
                },
                "stats": {
                    "name": "cpu.csv",
                    "values": [
                        {
                            "stat": {
                                "name": "cpu:user"
                            }
                        },
                        {
                            "stat": {
                                "name": "cpu:iowait"
                            }
                        }
                    ]
                }
            }
        ]
    }
}
In this example, only the first GetLoggerStatsRequest->stats->values->stat element is honored. The second one gets lost. I can see that during remote debugging and the webservice reponse reflects that as well.

I tried to find out whether this only affects the "zimbraAdmin" webservice, so I tried to cross-check with the "zimbraMail" service. One suitable example request I could find is ModifyContactRequest (with multiple ModifyContactRequest->cn->a elements).
This request works correctly, but looking at the Java code it turns out the request data is parsed in a different way and not like the aforementioned example requests in the admin service.

With XML requests however, there are no such problems.

Has anybody else noticed this? Am I on to something or am I just doing it wrong?
Thanks for any thoughts on this.
Damini Vashishtha
Zimbra Employee
Zimbra Employee
Posts: 38
Joined: Tue Oct 18, 2022 12:16 pm

Re: Passing JSON arrays to the SOAP webservices - possible bug?

Post by Damini Vashishtha »

AdminCreateWaitSetRequest->add->a should be an array
example:

Code: Select all

{
    "Header": {
        "context": { .... }
    },
    "Body": {
        "AdminCreateWaitSetRequest": {
            "_jsns": "urn:zimbraAdmin",
            "add": {
                  "a": [{
                        "folderInterests": "2",
                        "name": "test_a@myzimbra",
                        "types": "all"
                    },
                    {
                        "folderInterests": "2,5",
                        "name": "test_b@myzimbra",
                        "types": "all"
                    }]   
                }
        }
    }
}

For GetLoggerStatsRequest:

Code: Select all

{
	"Body": {
        "GetLoggerStatsRequest": [
            {
                "_jsns": "urn:zimbraAdmin",
                "endTime": {
                    "time": "1692366330"
                },
                "startTime": {
                    "time": "1692366180"
                },
                "stats": {
                    "name": "cpu.csv",
                    "values": {
                            "stat": [{
                                "name": "cpu:user"
                            },
                             {
                                "name": "cpu:iowait"
                            }]
                        }
                }
            }
        ]
    }
}
Post Reply