function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Haris Osmanagic, B&HHaris Osmanagic, B&H 

Error when using readMetadata() with ApexClass

I am trying to get a list of all metadata objects with the given name. However, the code (in Java) 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() (https://www.salesforce.com/us/developer/docs/api_meta/Content/meta_retrieve.htm))?

Seems like renameMetadata() (https://www.salesforce.com/us/developer/docs/api_meta/Content/meta_renameMetadata.htm) doesn't work with ApexClasses either. Is it maybe a restriction in the API which prevents anyone from changing Apex code?
ShashankShashank (Salesforce Developers) 
As per documentation, The metadata type must match one of the values returned by the describeMetadata() call.

https://www.salesforce.com/us/developer/docs/api_meta/index_Left.htm#CSHID=meta_readMetadata.htm|StartTopic=Content%2Fmeta_readMetadata.htm|SkinName=webhelp

 
Haris Osmanagic, B&HHaris Osmanagic, B&H
That doesn't solve it. The metadata type, "ApexClass", is a standard type, and it exists it describeMetadata() results.