REST API unread counter

Have a great idea for extending Zimbra? Share ideas, ask questions, contribute, and get feedback.
m1nd_killer
Posts: 4
Joined: Tue Nov 07, 2017 10:05 am

REST API unread counter

Postby m1nd_killer » Tue Nov 07, 2017 10:20 am

Hello everyone!

I use your nice service in my job for our corporate needs.
So, in integration we tried to show user unread counter by using REST API.
I use the next request on the server-side:
https://my_server.com:7071/home/[user-name]/inbox?fmt=json&query=is:unread

And all works fine untill users have small unread counter.
We found one user who have 12k unread inbox letters and this case kills our server down.
The reason is a very huge response, cuz we get full text of the letter, and a lot of useless information for simple counter.

So, i hope u can help me somehow.
How can i get this info trough REST or SOAP without huge overhead?
Thank you.


User avatar
msquadrat
Advanced member
Advanced member
Posts: 102
Joined: Mon Oct 14, 2013 10:09 am

Re: REST API unread counter

Postby msquadrat » Tue Nov 07, 2017 11:51 am

You're probably looking for the GetFolder SOAP Request: https://files.zimbra.com/docs/soap_api/ ... older.html
m1nd_killer
Posts: 4
Joined: Tue Nov 07, 2017 10:05 am

Re: REST API unread counter

Postby m1nd_killer » Tue Nov 07, 2017 2:07 pm

msquadrat wrote:You're probably looking for the GetFolder SOAP Request: https://files.zimbra.com/docs/soap_api/ ... older.html

Hello. Thank you for this link.
But how can i get unread inbox letters for particular user by using this SOAP request?
And i need to have access to info trough any type of username. Real name or alias.
By the way, we can see that this request gives us big overhead too...
Can it really help me somehow?
shrikant-prasad
Posts: 11
Joined: Fri Jun 09, 2017 4:57 am

Re: REST API unread counter

Postby shrikant-prasad » Thu Nov 09, 2017 7:17 am

you can get the unread count in GetFolderResponse:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:zimbra" xmlns:urn1="urn:zimbraMail">
<soapenv:Header>
<urn:context>
<urn:authToken><auth_token_of_user></urn:authToken>
</urn:context>
</soapenv:Header>
<soapenv:Body>
<urn1:GetFolderRequest>
<urn1:folder l="2"/> --2 id of Inbox folder
</urn1:GetFolderRequest>
</soapenv:Body>
</soapenv:Envelope>


<GetFolderResponse xmlns="urn:zimbraMail">
<folder i4ms="11409" rev="1" i4next="1862" f="u" ms="1" deletable="0" l="1" uuid="388e04a0-6e55-43f2-bbca-b069ad7dd9c2" n="79" luuid="116d4141-7fdd-4b23-9d84-ea9dd66d7d2a" activesyncdisabled="0" absFolderPath="/Inbox" view="message" s="303403" u="65" name="Inbox" id="2" webOfflineSyncDays="30"/>
</GetFolderResponse>
m1nd_killer
Posts: 4
Joined: Tue Nov 07, 2017 10:05 am

Re: REST API unread counter

Postby m1nd_killer » Fri Nov 10, 2017 10:52 am

shrikant-prasad wrote:you can get the unread count in GetFolderResponse:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:zimbra" xmlns:urn1="urn:zimbraMail">
<soapenv:Header>
<urn:context>
<urn:authToken><auth_token_of_user></urn:authToken>
</urn:context>
</soapenv:Header>
<soapenv:Body>
<urn1:GetFolderRequest>
<urn1:folder l="2"/> --2 id of Inbox folder
</urn1:GetFolderRequest>
</soapenv:Body>
</soapenv:Envelope>


<GetFolderResponse xmlns="urn:zimbraMail">
<folder i4ms="11409" rev="1" i4next="1862" f="u" ms="1" deletable="0" l="1" uuid="388e04a0-6e55-43f2-bbca-b069ad7dd9c2" n="79" luuid="116d4141-7fdd-4b23-9d84-ea9dd66d7d2a" activesyncdisabled="0" absFolderPath="/Inbox" view="message" s="303403" u="65" name="Inbox" id="2" webOfflineSyncDays="30"/>
</GetFolderResponse>


Hello.
Thank you for your post.
This request work nice, but the problem is <auth_token_of_user>.
I cant get it without name and password of user.
When i use the REST API, i can use the admin-account to get info, but for this request if i use admin-account, i get unread counter for admin.
The issue that i try to resolve is taking this counter without user login, by user name, using my admin-account.
Funny then i can take full messaging history by the admin-account, but cant get only counters.
User avatar
ccelis5215
Outstanding Member
Outstanding Member
Posts: 530
Joined: Sat Sep 13, 2014 2:04 am
Location: Caracas - Venezuela
ZCS/ZD Version: 8.0.9.GA.6191.UBUNTU12.64 FOSS

Re: REST API unread counter

Postby ccelis5215 » Fri Nov 10, 2017 12:29 pm

m1nd_killer wrote:Hello.
Thank you for your post.
This request work nice, but the problem is <auth_token_of_user>.
I cant get it without name and password of user.
When i use the REST API, i can use the admin-account to get info, but for this request if i use admin-account, i get unread counter for admin.
The issue that i try to resolve is taking this counter without user login, by user name, using my admin-account.
Funny then i can take full messaging history by the admin-account, but cant get only counters.


Hello, did you try

Code: Select all

zmsoap -z -m accounttocheck GetFolderRequest


as zimbra user

ccelis
m1nd_killer
Posts: 4
Joined: Tue Nov 07, 2017 10:05 am

Re: REST API unread counter

Postby m1nd_killer » Mon Nov 13, 2017 4:46 pm

Hello everyone.

Thank you for help.
I have found what i needed.

I have fixed my issue by next solution:
1. I get token by AuthRequest with admin-account.
2. I get user-token by DelegateAuthRequest with user-account name.
3. And then i use GetItemRequest with authToken from the 2nd step.

All works fine. Three requests... But it is better than 1st solution.

Thank you, again.

Return to “Developers”

Who is online

Users browsing this forum: No registered users and 4 guests