I am trying to get Apex to describe the fields present on certain sObjects, everything I try works perfectly in the developer console but when I put the code into an Apex class and access it via a custom REST endpoint it works fine for the Lead object but stops working for the Task object.

I have tried several different ways of accessing this information:


works in developer console while in the custom REST endpoint


returns null so it crashes


works in developer console but returns an empty array in my custom REST endpoint, also I would really prefer if I could select the object dynamically which this approach does not allow.


This one is a bit more roundabout but I was trying anything I could think of, but its results were identical to the previous one

Ive seen some similar posts with some proposed solutions but none of them seem to work for me, the API version of the class is 31.0 so I dont think the solution posted Schema.getGlobalDescribe returning different data from Developer Console is relevant

I also saw some stuff that made me think it might be related to the API restrictions of my managed package but I looked at the "API Access Privileges" for my package there is no option for the "Task" object so I dont know if im missing something or if that object is not API restricted or what.

1 Answer 1


it could be ( my guess) as simple as profile permission or sharing or OWD around tasks. Do you want to open up tasks for the integration profile you might be using just in case..

  • my profile is System Administrator, my apex class is set "without sharing" and i have no idea what OWD is.
    – user8246
    Jan 16, 2015 at 6:08
  • I looked into OWD and it doesnt seem that the Task object is not one of the objects that has settings in that list, is there some sort of object permissions hierarchy? like an object from which Task inherits its permissions?
    – user8246
    Jan 16, 2015 at 10:51
  • Task object comes under Activity. ( usually set as controlled by parent). So whatever you setup for Activity is applicable to Task and Event both
    – Manju
    Jan 19, 2015 at 2:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .