1

I have this method:

    protected void PerformQuery()
    {
        string sStatus = "";
        String requestId = "";
        string sOverallStatus = "";
        string sOverallStatusMessage = "";

        QueryDefinition qd = new QueryDefinition();
        qd.Name = "SentEmails";
        qd.CustomerKey = "SentEmails";

        PerformResult[] results = client.Perform(new PerformOptions(), "start", new APIObject[] { qd }, out sOverallStatus, out sOverallStatusMessage, out requestId);

        DisplayPerformResults(sStatus, results);
    }

But the result is an Error:

Overall Status: Error

Number of Results: 1

Status Message: Exception occurred during [Schedule::Start] ErrorID = 80779739

3
  • Are you looking to execute a SOQL using .Net and process those query results? Feb 25 '15 at 19:44
  • I assume this is related to ExactTarget/MarketingCloud. I've added the tag for this. Feb 25 '15 at 20:09
  • in ExactTarget/MarketingCloud I have a Query with CustomerKey = "SentEmails" which writes to a DataExtension, and I want to start this query using an API call Feb 25 '15 at 20:12
0

Take a look at this page on the Help site:

Performing a Query Activity Using the SOAP Web Service API

Here's a sample SOAP envelope that I executed successfully. NOTE: You need to retrieve the ObjectID of the QueryDefinition first. You can't just perform the QueryDefinition using the CustomerKey.

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
   <s:Header>
      <a:Action s:mustUnderstand="1">Perform</a:Action>
      <a:MessageID>urn:uuid:bf68161e-a8d0-4e8f-a2d4-2bf168a12b93</a:MessageID>
      <a:ReplyTo>
         <a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>
      </a:ReplyTo>
      <a:To s:mustUnderstand="1">https://webservice.exacttarget.com/Service.asmx</a:To>
      <o:Security xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" s:mustUnderstand="1">
         <u:Timestamp u:Id="_0">
            <u:Created>2015-03-02T15:07:51.991Z</u:Created>
            <u:Expires>2015-03-02T15:12:51.991Z</u:Expires>
         </u:Timestamp>
         <o:UsernameToken u:Id="uuid-f71147d1-508a-4a87-aa13-bfc8b9da4a38-27">
            <o:Username><!-- Removed--></o:Username>
            <o:Password><!-- Removed--></o:Password>
         </o:UsernameToken>
      </o:Security>
   </s:Header>
   <s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <PerformRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
         <Options>
            <SendResponseTo>
               <ResponseType>email</ResponseType>
               <ResponseAddress>aspriggs@degdigital.com</ResponseAddress>
               <RespondWhen>Always</RespondWhen>
               <IncludeResults>true</IncludeResults>
               <IncludeObjects>true</IncludeObjects>
            </SendResponseTo>
            <ConversationID>4e13ac98-63f8-4d23-ad5a-60e5eef7eb4b</ConversationID>
            <SequenceCode>1</SequenceCode>
            <CallsInConversation>1</CallsInConversation>
            <RequestType>Asynchronous</RequestType>
         </Options>
         <Action>Start</Action>
         <Definitions>
            <Definition xsi:type="QueryDefinition">
               <PartnerKey xsi:nil="true" />
               <ObjectID>86597061-370c-4608-b48f-3aa963d2d963</ObjectID>
            </Definition>
         </Definitions>
      </PerformRequestMsg>
   </s:Body>
</s:Envelope>

UPDATE: Retrieve QueryDefinition ObjectID:

<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
   <s:Header>
      <a:Action s:mustUnderstand="1">Retrieve</a:Action>
      <a:MessageID>urn:uuid:16b5bc0e-7c78-421d-8958-f91312b23ed1</a:MessageID>
      <a:ReplyTo>
         <a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>
      </a:ReplyTo>
      <a:To s:mustUnderstand="1">https://webservice.exacttarget.com/Service.asmx</a:To>
      <o:Security xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" s:mustUnderstand="1">
         <u:Timestamp u:Id="_0">
            <u:Created>2015-03-02T17:21:01.387Z</u:Created>
            <u:Expires>2015-03-02T17:26:01.387Z</u:Expires>
         </u:Timestamp>
         <o:UsernameToken u:Id="uuid-d4b6a237-b813-439d-8c6f-fe5ad929dd8e-3">
            <o:Username><!-- Removed--></o:Username>
            <o:Password><!-- Removed--></o:Password>
         </o:UsernameToken>
      </o:Security>
   </s:Header>
   <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>BUSINESS UNIT MID GOES HERE</ClientID>
            </ClientIDs>
            <ObjectType>QueryDefinition</ObjectType>
            <Properties>ObjectID</Properties>
            <Filter xsi:type="SimpleFilterPart">
               <Property>CustomerKey</Property>
               <SimpleOperator>equals</SimpleOperator>
               <Value>EXTERNAL KEY GOES HERE</Value>
            </Filter>
            <QueryAllAccounts>true</QueryAllAccounts>
            <Retrieves />
         </RetrieveRequest>
      </RetrieveRequestMsg>
   </s:Body>
</s:Envelope>

I find that the SOAP envelopes that are available in the examples and here (direct .ZIP download) are the best way to form the API calls -- in whatever dev environment.

5
  • Thank you, i understand. Do you know how to retrieve the ObjectID of the QueryDefinition using C# Mar 2 '15 at 16:47
  • Updated my example above to include the QueryDefinition retrieve SOAP envelope. Mar 2 '15 at 17:25
  • Great, Thank you! I guess there are no equivalent set of examples in C#. Mar 2 '15 at 18:50
  • How do you construct those SOAP envelopes? is there a tool you can recommend? Mar 2 '15 at 18:50
  • These SOAP envelopes are captured from the C# calls I'm doing in LINQPad. Mar 2 '15 at 21:29
0

NOTE: You need to retrieve the ObjectID of the QueryDefinition first. You can't just perform the QueryDefinition using the CustomerKey.

    protected string RetriveQueryID(string sQeryDefKey)
    {
        string sObjectId = "";
        txtResponse.Text = "";

        string sStatus = "";
        String requestId = null;

        SimpleFilterPart sfp = new SimpleFilterPart();
        sfp.Property = "CustomerKey";
        sfp.SimpleOperator = SimpleOperators.equals;
        sfp.Value = new string[] { sQeryDefKey };

        RetrieveRequest rr = new RetrieveRequest();
        rr.ObjectType = "QueryDefinition";
        rr.Properties = new String[] { "ObjectID" };
        rr.Filter = sfp;

        APIObject[] objs = null;

        try
        {
            sStatus = client.Retrieve(rr, out requestId, out objs);
            sObjectId = objs[0].ObjectID;
            txtResponse.Text = sObjectId;
        }
        catch (Exception e)
        {
            txtResponse.Text = e.ToString();
        }

        return sObjectId;
    }

    protected void PerformQuery(string sQeryDefKey)
    {
        txtResponse.Text = "";

        string sStatus = "";
        String requestId = "";
        string sOverallStatus = "";
        string sOverallStatusMessage = "";

        QueryDefinition qd = new QueryDefinition();
        qd.ObjectID = RetriveQueryID(sQeryDefKey);
        //qd.Name = sQeryDefKey;
        //qd.CustomerKey = sQeryDefKey;

        PerformResult[] results = client.Perform(new PerformOptions(), "start", new APIObject[] { qd }, out sOverallStatus, out sOverallStatusMessage, out requestId);

        DisplayPerformResults(sOverallStatus, results);
    }
1
  • Why not just update your question with your code? Mar 9 '15 at 21:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.