Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch request doesn't work as expected #37

Open
sirio81 opened this issue Jul 4, 2023 · 0 comments
Open

Batch request doesn't work as expected #37

sirio81 opened this issue Jul 4, 2023 · 0 comments

Comments

@sirio81
Copy link

sirio81 commented Jul 4, 2023

In the following example I try to run a batch request to get 3 folders for the same account.
Please try to indent and read the output of get_fault_message().
You'll notice that the request syntax is wrong!
The problem shows up adding 3 or more batch requests.

Script:

admin_token = auth.authenticate(
    url,
    admin_name,
    admin_password,
    admin_auth=True,
    use_password=True
)

request = comm.gen_request(token=admin_token)

request.add_request(
    'DelegateAuthRequest',
    {
        'account': {
            'by': 'name',
            '_content': '[email protected]'
        }
    },
    'urn:zimbraAdmin'
)

response = comm.send_request(request)
new_token = response.get_response()['DelegateAuthResponse']['authToken']['_content']

request = comm.gen_request(token=new_token, set_batch=True)

request_inbox_id = request.add_request(
    'GetFolderRequest',
    {
        'folder': {'path': '/Inbox'},
    },
    'urn:zimbraMail'
)

request_sent_id = request.add_request(
    'GetFolderRequest',
    {
        'folder': {'path': '/Sent'},
    },
    'urn:zimbraMail'
)

request_trash_id = request.add_request(
    'GetFolderRequest',
    {
        'folder': {'path': '/Trash'},
    },
    'urn:zimbraMail'
)

response = comm.send_request(request)

print('request id(s):', request_inbox_id, request_sent_id, request_trash_id)
print(response.is_fault())
print(response.get_fault_code())
print(response.get_fault_message())

Output:

request id(s): 1 2 3 True service.PARSE_ERROR parse error: expected character: { found:[: {"Header": {"context": {"_jsns": "urn:zimbra", "format": {"type": "js"}, "authToken": {"_content": "REMOVED"}}}, "Body": {"BatchRequest": {"_jsns": "urn:zimbra", "onerror": null, "GetFolderRequest": [[{"folder": {"path": "/Inbox"}, "_jsns": "urn:zimbraMail", "requestId": 1}, {"folder": {"path": "/Sent"}, "_jsns": "urn:zimbraMail", "requestId": 2}], {"folder": {"path": "/Trash"}, "_jsns": "urn:zimbraMail", "requestId": 3}]}}}

Is my code correct?
If so, could you please fix this issue?

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant