Null Object Data in Java API

I’m using Java to access the API, and am attempting to view Task data by printing it to the console. One data field in particular is the notes field. When I view Task notes in JSON through the web browser, I can see that data field and its value just fine. However, when I access that same Task through Java and print the notes to the console, it comes up as null. In fact, when debugging and viewing the object attributes, almost all of them are null except for name, id, hearted, liked, numHearts, and numLikes. Many of the other attributes have values but are showing up as null in Java.

Is this an issue with the API, or am I not quite understanding how the Java objects are supposed to work?

What this may be is that you’re getting the objects in their compact form, and you need to use the opt_fields parameter to request the specific fields you want. For more details, see:

Let us know if that solves the issue, or if that’s not what’s going on.

Actually I don’t think that was the issue here, but the opt_fields documentation did help me realize the issue. I was attempting to access the notes field by searching through a Task list created with the findByTag method. I’m guessing to make it more efficient, this method only provides id and name. When I used the findById method to get a distinct Task, then it worked. Thanks for the help!

1 Like