I have a code snippet that I try to create a query and perform it. I am able to create the query but it does not perform the query. Instead, it gives that error: Exception occurred during [Schedule::Start]

    $pr = new ExactTarget_PerformRequestMsg();

    $pr->Action = "Start"; 
    $pr->Definitions =  array();

    $qd = new ExactTarget_QueryDefinition();
    $qd->Name = "de_sql";
    $qd->CustomerKey = "de_sql";
    $qd->Description = "API_Query";
    $qd->TargetUpdateType = "Overwrite";                                   
    $qd->TargetType = "DE";
    $qd->QueryText = "SELECT sub.Localization, sub.SubscriberKey FROM ( SELECT a.SubscriberKey, a.Localization, row_number() OVER (PARTITION BY a.Localization ORDER BY a.SubscriberKey desc) as rowindex FROM " . $filter . " a WHERE a.SubscriberKey IN (SELECT SubscriberKey FROM ENT._Subscribers WHERE Status = 'Active') ) sub WHERE rowindex = 1 ";                    
    $ibo = new ExactTarget_InteractionBaseObject();
    $ibo->CustomerKey = "EF967E69-CD41-40F2-A896-4362802B7B79";
    $ibo->Name = "prooflist_test";                                                               
    $qd->DataExtensionTarget = $ibo;                                                                                                      

    $object = new SoapVar($qd, SOAP_ENC_OBJECT, 'QueryDefinition', "http://exacttarget.com/wsdl/partnerAPI");

    $request = new ExactTarget_CreateRequest();
    $request->Options = NULL;
    $request->Objects = array($object);
    $results = $client->Create($request);
    $p_results = array($results);

    $pr->Definitions[] = new SoapVar($qd, SOAP_ENC_OBJECT, 'QueryDefinition', "http://exacttarget.com/wsdl/partnerAPI");
    $pr->Options = NULL;
    $results2 = $client->Perform($pr); 

1 Answer 1


You can't just perform the QueryDefinition using the CustomerKey, you must use the ObjectID for the Query definition.

You can find the ObjectID by performing a retrieve on the QueryDefinition Object. Below is a sample SOAP Body envelope to retrieve QueryDefinition object.

<s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
           <ClientID>BU MID here</ClientID>
        <Filter xsi:type="SimpleFilterPart">
           <Value>Query External Key here</Value>
        <Retrieves />

  • Could you please explain how can I use this code with my PHP code? Jan 22, 2018 at 7:58
  • When you're able to create the query successfully, use the ObjectID value returned during the creation process and set it to: $qd->ID = "ObjectID Here"; Jan 22, 2018 at 15:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .