ユースケース:Apex を使用した CPQ API の呼び出しまたはテスト

  • リリースバージョン: Australia
  • 更新日 2026年03月12日
  • 所要時間:1分
  • Apex を使用して CPQ API を呼び出したりテストしたりする方法について説明します。

    Apex コードで CPQ の使用をテストする最も簡単な方法は、SFDC の開発者コンソールを使用することです。

    ユーザーインターフェイス

    コンソールからスクリプトをテストするには、「exec」関数を使用してコードを大きなクラスにラップする必要があります。例:

    public class testGetConfig { public static void exec() {

    コードを保存し、[デバッグ] メニューで [匿名ウィンドウを実行] をクリックします。

    デバッグメニュー

    [匿名実行] ウィンドウで、コード functionName.exec(); を実行します。

    CPQ API を呼び出す Apex コードの例

    次のコードは、潜在的な構成に関する情報を取得する Apex クラスの例です。

    1 public class testGetConfig {
    2 	public static void exec(){
    3
    4 		HttpRequest httpRequest = new HttpRequest();
    httpRequest.setEndpoint('https://tenant.sector.logik.io/api/[config id here]');
    httpRequest.setTimeout(5000);
    5
    6 		httpRequest.setMethod('GET'); httpRequest.setHeader('Content-Type', 'application/json');
    7
    8 		httpRequest.setHeader('Authorization', 'Bearer [INSERT TOKEN HERE]');
    httpRequest.setHeader('Origin', 'https://tenant.sector.logik.io/');
    9
    10 		Http http = new Http(); HttpResponse httpResponse;
    11
    12 		httpResponse = http.send(httpRequest);
    13
    14 	}
    15 }

    このコードは testGetConfig.exec(); として実行されます。