Reputation: 11
we have been using the ASANA API about 4 month, but today we started get an error trying to create task in Asana:
5:15:48,208 ERROR [stderr] (pool-13-thread-1) Exception in thread "pool-13-thread-1" com.sun.jersey.api.client.ClientHandlerException: org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "num_hearts" (Class net.joelinn.asana.tasks.Task), not marked as ignorable
05:15:48,210 ERROR [stderr] (pool-13-thread-1) at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@6eae04be; line: 1, column: 296] (through reference chain: net.joelinn.asana.tasks.Task["num_hearts"])
the error happens on client.createTask() call, see the code below:
protected void createProjectTasks(Project template, AsanaDetails asanaDetails, Long createdProjectId) {
try {
String asanaWorkspaceName = asanaDetails.getWorkspaceName();
Asana asana = new Asana(asanaDetails.getApiKey());
Tasks tasks = asana.projects().getTasks(template.id);
Workspace workspace = getWorkspace(asana, asanaWorkspaceName);
if (workspace == null) {
throw new AsanaException("Asana workspace with name " + asanaWorkspaceName + " is not found");
}
if (tasks == null) {
return;
}
Collections.reverse(tasks);
TasksClient client = asana.tasks();
for (Task task : tasks) {
TaskRequestBuilder taskRequestBuilder = new TaskRequestBuilder();
if (StringUtils.isNotBlank(task.name)) {
taskRequestBuilder.name(task.name);
taskRequestBuilder.completed(false);
taskRequestBuilder.addProject(createdProjectId);
taskRequestBuilder.workspace(workspace.id);
client.createTask(taskRequestBuilder);
}
}
} catch (ApiException e) {
throw new AsanaException(e.getMessage());
}
}
I checked the Task class, the are no field there annotated with "num_hearts", so, I'm a bit confused what got broken here, we haven't made any code changes for about a month...
and here is the api version:
<dependency>
<groupId>net.joelinn</groupId>
<artifactId>asana</artifactId>
<version>0.5.4</version>
</dependency>
Any thoughts? Thanks in advance
Upvotes: 1
Views: 307
Reputation: 21
We're happy to have released support in the API for hearts in both tasks and stories. These include the new fields, "hearted", "hearts", and "num_hearts". You can read more about this in our documentation.
Unfortunately, your client threw an error because it reached a new field (num_hearts) which it did not recognize. Since the client appears to be open source, you might want to send them a pull request to add support for the new hearts attributes. Alternatively, it may be worth to generalize the client so it does not throw an error when we add new fields in the future. In order to keep the API up-to-date with product developments, we will from time to time add fields and endpoints. You can rely on existing fields not going away, but it's bad to rely on no new fields being added.
Upvotes: 2