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
takahirotakahiro 

Metadata APIにてObjectのMetadataを取得する方法について

 

Metadata APIにて、リストビューの設定内容を取得したいと考えております。

その場合のMetadata APIにてObjectのMetadataを取得する方法を教えていただけないでしょうか。

 

SOAPでのRequest、もしくは、どのようにやっているのでしょうか。 

 

Jon SnowJon Snow
APEXからRest APIをリクエストし、返したレスポンス文字列をJSONに変換する必要です。

APEX:
  HttpRequest req = new HttpRequest();
  req.setHeader('Authorization','Bearer '+UserInfo.getSessionId());
  endpoint = 'https://ap.salesforce.com/services/data/v29.0/sobjects/Account/';   //取引先の場合
  req.setEndpoint(endpoint);
  req.setMethod('GET');
  Http http = new Http();
  HTTPResponse res = http.send(req);
  String responseString = res.getBody();
  Map<String,Object> objMeta = (Map<String,Object>)JSON.deserializeUntyped(responseString);
  system.debug('Account's metadata : ' + objMeta);

※リモートサイトの設定に、「https://ap.salesforce.com」の追加が必要です。
参照:https://www.salesforce.com/us/developer/docs/api_rest/