> For the complete documentation index, see [llms.txt](https://200ok.gitbook.io/200ok-documents/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://200ok.gitbook.io/200ok-documents/user-manual/invoke-integration-channel/unleash-the-power-invoke-with-apex.md).

# Unleash the Power: Invoke with Apex!

Using Apex, you can invoke the Integration Channel to make callouts to an external system.\
\
Here, you have two ways to invoke integration channel in Apex :-\
\
&#x20;    1\. Simulate the Integration Channel in synchronous mode\
&#x20;    2\. Simulate the Integration Channel in Asynchronous mode\
\
**1. Simulate the Integration Channel in synchronous mode**

&#x20;  It will execute the integration channel in synchronous mode you can refer to below.

**How to use integration channel in Apex**

To simulate the Integration channel in apex, use the following lines of code.\
\
**lwapic.ICChannelRequest instance = new lwapic.ICChannelRequest();**\
**instance.channelName = 'Push\_Data\_to\_Power\_BI'; // pass the channel API name**\
**//instance.requestPayload = '{"rows":\[{"StageName":"Prospecting","Name":"Sobha 200 OK"}]}'; // If required pass the body**\
**instance.queryParams = value 1, value 2,value 3; //If you want to pass values dynamically eg :- {0},{1},{2},... are set in endpoint or query params of integration channel and comma(,) is the request data separator**\
**List\<lwapic.ICChannelRequest> resList= new List\<lwapic.ICChannelRequest>();**\
**resList.add(instance);**\
**List\<lwapic.ICResponseWrapper> respWrapList = lwapic.ICControllerSync.execute(resList);**\
\
If Integration channel is excepting some inputs to be passed while simulating the channel at runtime, in the above code, you have global class named ‘ ICChannelRequest ’. In the same class, there are several global variables( recordId, queryParams, requestPayload, etc. ) by which you are going to set the values to the channel at runtime.\
\
Navigate to the developer console by using the setup gear icon. Then, for understanding the process, navigate to execute anonymous window and paste the above code to simulate the channel. You can use the above code in any class or any method as per the requirement, as shown in the image below.

<figure><img src="https://lh7-us.googleusercontent.com/7blCkMK7LEd-ftuv41o74VcIcnKHvGYxbzDn8lYctViN79P5E5KZ-2WZNHxUc1NLUkmueWZY8xJ063gJOKly-3bqZeql3ZoqEhEAakj3nYqTnq7yL-MXt48wwGvBc6NT4IEXlP_-SWZQ_E2kuWkqCMQ" alt="" width="563"><figcaption></figcaption></figure>

**\*Note :-** After simulating the integration channel in synchronous mode, you can obtain the response of the channel using the global class named 'ICResponseWrapper' to use it further.\
\
**2. Simulate the Integration Channel in Asynchronous mode**\
\
It will execute the integration channel in asynchronous mode. You can refer to below

Similar to synchronous mode, only change is instead of lwapic.ICControllerSync.execute(resList); you need to use lwapic.ICControllerASync.execute(resList); in Apex to simulate the channel in asynchronous mode, as shown below.\
\
**lwapic.ICChannelRequest instance = new lwapic.ICChannelRequest();**\
**instance.channelName = 'Push\_Data\_to\_Power\_BI'; // pass the channel API name**\
**//instance.requestPayload = '{"rows":\[{"StageName":"Prospecting","Name":"Sobha 200 OK"}]}'; // If required pass the body**\
**instance.queryParams = value 1, value 2,value 3; //If you want to pass values dynamically eg :- {0},{1},{2},... are set in endpoint or query params of integration channel and comma(,) is the request data separator**\
**List\<lwapic.ICChannelRequest> resList= new List\<lwapic.ICChannelRequest>();**\
**resList.add(instance);**\
**lwapic.ICControllerASync.execute(resList); // Don't store in any variable as Sync execution because it doesn't return any response in ASync Execution**\ <br>

<figure><img src="https://lh7-us.googleusercontent.com/CMl3gLKYqTRC7kuG4xtE91WWJZs74E5YmRFFlKE3L2MeqtiJXwmdKlnPouA19gk64QndU7RFK8Geew0efLuaLgy5ex81ENUOVruPMVQWXiMFQkpjo1tF-7J2k2NkScREZcXujnmYbfyGJuVFnc_ChFw" alt="" width="563"><figcaption></figcaption></figure>

**\*Note :-**  After simulating the integration channel in asynchronous mode, no output will be immediately available since it operates asynchronously.<br>
