Search code examples
javajsonapirestattask

AtTask API only returns a subset of the fields on an object


When I use the /search or the &method=get on a company (and other objects), I only get a subset of the fields in return. How do I get all of the fields?

i.e.

https://example.com/attask/api/company?id=52cc12f0000b053291be85eb0fb10da0&method=get

returns:

{"data":{"ID":"52cc12f0000b053291be85eb0fb10da0","name":"SomeCompany","objCode":"CMPY","hasNotes":false,"notes":null,"lastNote":null,"lastNoteID":null}}

But the Company object also has (from the API Docs): --SNIP--

categoryID
API Key: categoryID
Field Type: string

customerID
API Key: customerID
Field Type: string

enteredByID
API Key: enteredByID
Field Type: string

entryDate
API Key: entryDate
Field Type: dateTime

extRefID
API Key: extRefID
Field Type: string

hasRateOverride
API Key: hasRateOverride
Field Type: boolean

lastUpdateDate
API Key: lastUpdateDate
Field Type: dateTime

lastUpdatedByID
API Key: lastUpdatedByID
Field Type: string

--/SNIP--
How do I get these Fields to return when I request the object?

Please NOTE: I am also working on a Java Project to learn the API. I have downloaded and am using the JAVA API examples from the community site, so I'm hoping your answer will also apply there.


Solution

  • AtTask uses lazy loading of return fields with only a small subset of fields returned by default. You can specify which fields you want in your result by passing a comma-separated list of field names as the fields parameter like this:

    https://mydomain.com/attask/api/company?id=52cc12f0000b053291be85eb0fb10da0&method=get&fields=name,entryDate
    

    Which will return the name and entryDate of the company record.