LoginSignup
1
0

SalesforceのApex classをダウンロードする【Tooling APIをPostmanから使う】

Last updated at Posted at 2023-12-21

Postmanを使って確かめたいと思います。
PostmanからSalesforceにアクセスする方法は、以下を参考にして下さい。

EntityDefinitionオブジェクトの検索

image.png

qのパラメータに以下を設定します。SOQL文のスペースを+で置き換えた形です。

SELECT+Id,FullName+FROM+ApexClass

エラーになりますね。結果が11返ってくるので1つでないとダメと言っている感じです。
このエラーはトレイルヘッドで良く見かけますね。

[
{
"message": "When retrieving results with Metadata or FullName fields, the query qualificatio​ns must specify no more than one row for retrieval. Result size: 11",
"errorCode": "MALFORMED_QUERY"
}
]

確かに11個のApex Classがあります。

image.png

適当にWHERE句を追加します。

SELECT+Id,FullName+FROM+ApexClass+WHERE+ApiVersion='58.0'

他の項目を使っても同じエラーになるんですよねぇ。何?

[
{
"message": "\nFullName FROM ApexClass WHERE ApiVersion='58.0'\n ^\nERROR at Row:1:Column:41\nvalue of filter criterion for field 'ApiVersion' must be of type double and should not be enclosed in quotes",
"errorCode": "INVALID_FIELD"
}
]

あああ、数値だった

SELECT+Id,FullName+FROM+ApexClass+WHERE+ApiVersion=58.0

58.0も複数あるな。やっぱりName系を使う必要があるかも

[
{
"message": "When retrieving results with Metadata or FullName fields, the query qualificatio​ns must specify no more than one row for retrieval. Result size: 2",
"errorCode": "MALFORMED_QUERY"
}
]

Nameが使えそう

SELECT+Id,FullName,body+FROM+ApexClass+WHERE+Name='Apex1'

取得できた

image.png

image.png

イベントログみたいにダウンロードできるか?

{{_endpoint}}/services/data/v{{version}}/tooling/sobjects/ApexClass/:ApexId

詳細情報が取得できただけですね。やはりコードはBodyみたい。

image.png

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0