This function executes the instantiated Marketing Cloud API Object. It returns a RequestID value (because it is executed asynchronously), an API Object containing a status message and an error code value.



Ordinal Type Required Description
1 API Object True The API Object to be executed
2 String True The AMPscript variable in which the resulting status message is stored
3 Variable True The AMPscript variable in which the resulting RequestID is stored


The following example logs an unsubscribe event for a specific email Subscriber.


set @er = CreateObject("ExecuteRequest")

set @prop = CreateObject("APIProperty")
SetObjectProperty(@prop, "Name", "SubscriberKey")
SetObjectProperty(@prop, "Value", "9496")
AddObjectArrayItem(@er, "Parameters", @prop)

set @prop = CreateObject("APIProperty")
SetObjectProperty(@prop, "Name", "Reason")
SetObjectProperty(@prop, "Value", "Hates getting emails")
AddObjectArrayItem(@er, "Parameters", @prop)

set @invokeStatusObj = InvokeExecute(@er, @invokeStatusMessage, @invokeRequestId)

SET @invokeResponse = Row(@invokeStatusObj, 1)
SET @invokeStatus = Field(@invokeResponse,'StatusMessage')
SET @invokeErrorCode = Field(@invokeResponse,'ErrorCode')

invokeStatusMessage: %%=v(@invokeStatusMessage)=%%
<br>invokeRequestId: %%=v(@invokeRequestId)=%%
<br>invokeStatus: %%=v(@invokeStatus)=%%
<br>invokeErrorCode: %%=v(@invokeErrorCode)=%%


invokeStatusMessage: OK
invokeRequestId: 89d0a3ad-00b8-4347-858b-41b672984359
invokeStatus: Event posted
invokeErrorCode: 0