Newer Version Available

This content describes an older version of this product. View Latest

describeMetadata()

This call retrieves the metadata that describes your organization. This information includes Apex classes and triggers, custom objects, custom fields on standard objects, tab sets that define an app, and many other metadata types.

Syntax

1DescribeMetadataResult = metadataConnection.describeMetadata(double apiVersion);

Arguments

Name Type Description
apiVersion double The API version for which you want metadata; for example, 48.0.

Permissions

Your client application must be logged in with the Modify All Data or Modify Metadata Through Metadata API Functions permission.

If a user requires access to metadata but not to data, you can enable the Modify Metadata Through Metadata API Functions permission to give the access the user needs without providing access to org data.

Note

Sample Code—Java

1public void describeMetadata() {
2  try {
3    double apiVersion = 21.0;
4    // Assuming that the SOAP binding has already been established.
5    DescribeMetadataResult res = 
6        metadataConnection.describeMetadata(apiVersion);
7    StringBuffer sb = new StringBuffer();
8    if (res != null && res.getMetadataObjects().length > 0) {
9      for (DescribeMetadataObject obj : res.getMetadataObjects()) {
10        sb.append("***************************************************\n");
11        sb.append("XMLName: " + obj.getXmlName() + "\n");
12        sb.append("DirName: " + obj.getDirectoryName() + "\n");
13        sb.append("Suffix: " + obj.getSuffix() + "\n");
14        sb.append("***************************************************\n");
15      }
16    } else {
17      sb.append("Failed to obtain metadata types.");
18    }
19    System.out.println(sb.toString());
20  } catch (ConnectionException ce) {
21    ce.printStackTrace();
22  }
23}

When to Use describeMetadata() and describeValueType()?

Use the describeMetadata() call to get high-level information about all the metadata types that are available for your organization, such as type names and file suffixes. Use the describeValueType() call to get granular information about a specific metadata type, such as fields contained within the type.