# Events API endpoint help

**URL:** <https://forum.asana.com/t/events-api-endpoint-help/20809>\
**Category:** API & Developers\
**Created:** [25 April 2018 17:19 UTC](https://forum.asana.com/t/events-api-endpoint-help/20809 "2018-04-25T17:19:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_feist](https://luna1.co/8d76cd.png) [@Jason\_feist](https://forum.asana.com/u/Jason_feist)\
**Post date:** [25 April 2018 17:19 UTC](https://forum.asana.com/t/events-api-endpoint-help/20809/1 "2018-04-25T17:19:20Z")

</div>

I’m trying to schedule a job which runs periodically and queries the events API. I have everything up and running but I just don’t get any data returned. Here is what happens.

I query for all unarchived projects for our customer, this returns successfully. I iterate over the projects and call the endpoint with the project id, i.e. /events?resource=14321. I receive a 412 response code and get the sync token from the response. This token always seems to end with a “:0”. I stored the token and about half an hour later, I run the same query but this time I’m including the sync token, i.e. /events?resource=14321&sync=1231232313:0. I’m always getting a 200 response without any data, something like  
{“data”:,“sync”:“1231232313:1”}.  
Since the sync token has changed, I store the new token and the cycle continues from there, with the token incrementing after every call for the projects events endpoint. The problem I’m having is that this code has been running for 24 hours and every project returns an empty data array, and I know people are doing things in the application. Am I doing something wrong here? There don’t seem to be errors other than the expected 412 the first time I call this code.

I also tried doing the same thing for tasks, and the same empty data array is being returned.

---

<div class="post-metadata">

**Author:** ![Bastien\_Siebman](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/bastien_siebman/32/172354_2.png) [@Bastien\_Siebman](https://forum.asana.com/u/Bastien_Siebman)\
**Post date:** [26 April 2018 11:45 UTC](https://forum.asana.com/t/events-api-endpoint-help/20809/2 "2018-04-26T11:45:52Z")

</div>

I am not answering your question but did you consider using the official libraries to work with Asana API? That might be a little bit easier for you.

---

<div class="post-metadata">

**Author:** ![Jason\_feist](https://luna1.co/8d76cd.png) [@Jason\_feist](https://forum.asana.com/u/Jason_feist)\
**Post date:** [26 April 2018 15:27 UTC](https://forum.asana.com/t/events-api-endpoint-help/20809/3 "2018-04-26T15:27:59Z")

</div>

No, I’m using Java and the client libs don’t work. When calling the OAuthApp constructor and including a refresh token, I get an exception because the Credential object is being constructed wrong in the lib. I can get around this by building my own Credential object and setting it in the OAuth app. But even after doing that, the code just does endless polling of the endpoint. I get back no results, and a new sync token with every request. It’s coming from this code in EventsPageIterator:

while (true) {  
Collection result = super.next();  
if (result.size() \> 0) {  
return result;  
} else {  
try {  
Thread.sleep((Integer) request.options.get(“poll\_interval”) \* 1000);  
} catch (InterruptedException e) {  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![Bastien\_Siebman](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/bastien_siebman/32/172354_2.png) [@Bastien\_Siebman](https://forum.asana.com/u/Bastien_Siebman)\
**Post date:** [27 April 2018 06:57 UTC](https://forum.asana.com/t/events-api-endpoint-help/20809/4 "2018-04-27T06:57:30Z")

</div>

@Jeff_Schneider @Matt_Bramlage @johnnygoodnow are you aware of any bug with the Java library. ?

---

<div class="post-metadata">

**Author:** ![Jason\_feist](https://luna1.co/8d76cd.png) [@Jason\_feist](https://forum.asana.com/u/Jason_feist)\
**Post date:** [27 April 2018 15:43 UTC](https://forum.asana.com/t/events-api-endpoint-help/20809/5 "2018-04-27T15:43:30Z")

</div>

The specific location of the error is in the setRefreshToken method in Credential.java (in the google-oauth-client lib). When this is called in the constructor of OAuthApp.java, it is returning this error message “Please use the Builder and call setJsonFactory, setTransport, setClientAuthentication and setTokenServerUrl/setTokenServerEncodedUrl”. An easy fix is to build the Credential object with the builder and then set the tokens as they say.

credential = new Credential.Builder(BearerToken.authorizationHeaderAccessMethod())  
.setJsonFactory(GsonFactory.getDefaultInstance())  
.setTransport(new NetHttpTransport())  
.setClientAuthentication(new ClientParametersAuthentication(  
clientId,  
secretId))  
.setTokenServerUrl(new GenericUrl(TOKEN\_SERVER\_URL))  
.build();  
credential.setAccessToken(accessToken);  
credential.setRefreshToken(refreshToken);

As far as the endless polling, it’s not really a bug, but endlessly polling an endpoint in a while loop until you get some results back certainly seems odd to me though. I’d rather just get back an empty result set and a new sync token that I can use later. If there are no results, there are no results. No need to have a method that might never return that endlessly hits an endpoint. But yeah, the Java libs don’t work for my case.

---

<div class="post-metadata">

**Author:** ![johnnygoodnow](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/johnnygoodnow/32/12746_2.png) [@johnnygoodnow](https://forum.asana.com/u/johnnygoodnow)\
**Post date:** [30 April 2018 18:50 UTC](https://forum.asana.com/t/events-api-endpoint-help/20809/6 "2018-04-30T18:50:53Z")

</div>

Hi @Jason_feist,

Would you mind filing the OAuth issue as a bug under our [Java client library on Github](https://github.com/Asana/java-asana/issues)? We do realize there are some bugs in the Java client library that are more prevalent than our other libraries, and we’re actively working on making our client libraries better. That being said, apologies that it’s not working for your use case.

As for the events API, have you tried a simple test case on a test project? How often are you polling? If it’s over 24 hours, the token may have expired - in which case you’d get no events (because you’d be fetching a new token at that point, in which no events have happened); not sure if you saw that [in our docs](https://asana.com/developers/api-reference/events).

Could you manually try the following:

- Create a test project in Asana with no tasks
- Query for the events for that project, expecting a 412, and store the sync token.
- Create some new tasks in the project
- Query for events in that project, expecting a 200 and some events corresponding to your actions.

Another option is to verify this using cURL - does this issue still persist?

If the simple test case in Java does not work, can you write out that sample code so that we could further help you debug the issue?

---

<div class="post-metadata">

**Author:** ![Jason\_feist](https://luna1.co/8d76cd.png) [@Jason\_feist](https://forum.asana.com/u/Jason_feist)\
**Post date:** [1 May 2018 18:31 UTC](https://forum.asana.com/t/events-api-endpoint-help/20809/7 "2018-05-01T18:31:24Z")

</div>

Thanks for the reply. It looks like the OAuth issue was already created ([IllegalArgumentException from OAuthApp when passing in tokens · Issue #41 · Asana/java-asana · GitHub](https://github.com/Asana/java-asana/issues/41)). I’m not sure what happened, but my code has started returning results. There was an outage the day before I started testing this so maybe that affected things? I’m going to take your advice and set up a new test project and see what happens. I’m confident this code is set up properly though because it’s worked before.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/system/32/276370_2.png) [@system](https://forum.asana.com/u/system)\
**Post date:** [30 May 2025 19:08 UTC](https://forum.asana.com/t/events-api-endpoint-help/20809/8 "2025-05-30T19:08:07Z")

</div>

Closed on 30 May 2025 19:08 UTC


