I am trying to get a list of all metadata objects with the given name. However, the code below fails:

connection.readMetadata("ApexClass", new String[] {"SampleDeployClass"});

with this error:

Exception in thread "main" com.sforce.ws.SoapFaultException: INVALID_TYPE: This type of metadata is not available for this organization

Using connection.listMetadata() I am able to confirm that SampleDeployClass exists. I'm using a DE org, and the user has the Modify all data permission.

Is this something expexted (couldn't find it in the docs)? If yes, how am I able to confirm that a set of metadata objects already exists (other than retrieve())?


Seems like renameMetadata() doesn't work with ApexClasses either. Is it maybe a restriction in the API which prevents anyone from changing Apex code?


Nor does it work using JSForce, so it's not something related to the client code.

  • 1
    Did you find an answer to this? I've been banging my head against this as well.
    – Rockdocta
    Jan 24, 2015 at 4:01
  • @Rockdocta Nope, no answer here. I ended up using retrieve() as a workaround, but what I initially wanted to accomplish, I haven't. Jan 25, 2015 at 6:48
  • Can you post here what your retrieve code looks like?
    – Rockdocta
    Jan 25, 2015 at 12:14
  • 1
    Basically, it's this: gist.github.com/hariso/… Jan 28, 2015 at 14:08
  • I've been facing same kind of error, I'm trying to ReadMetadata only (ApexTrigger), but it return same error even in DE or Sandbox org. Does anyone know why? I'm not trying to update Trigger, I am only trying to read them.
    – VarunC
    May 13, 2015 at 12:33

1 Answer 1


I think you need to use Tooling API instead.

I'm using JSForce for this.

connection.tooling.sobject('ApexClass').retrieve('01p7R000007Axk8QAC', (error, result) => {

You must log in to answer this question.

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