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);
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 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"> <RetrieveRequest> <ClientIDs> <ClientID>BU MID here</ClientID> </ClientIDs> <ObjectType>QueryDefinition</ObjectType> <Properties>ObjectID</Properties> <Filter xsi:type="SimpleFilterPart"> <Property>CustomerKey</Property> <SimpleOperator>equals</SimpleOperator> <Value>Query External Key here</Value> </Filter> <QueryAllAccounts>true</QueryAllAccounts> <Retrieves /> </RetrieveRequest> </RetrieveRequestMsg>
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0