I notice that within the documentation for the SOAP API it has the fields FileSpec and FileType which leads me to believe that a query results can be stored as a csv file that would be found within the safehouse.

This is the soap envelope that im sending

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <CreateRequest xmlns="http://exacttarget.com/wsdl/partnerAPI">
      <Objects xsi:type="QueryDefinition">
        <QueryText>SELECT count(SubscriberKey) as COUNT from SOME_VALID_DE</QueryText>
    <fueloauth xmlns="http://exacttarget.com">{{auth token is here}}</fueloauth>

and the error that im getting:

Exception occurred during [CreateQueryDefinition] ErrorID: 181963199

There is also the field TargetType which I suspect might need to be populated for this to work, but cant find anything as to what options it can be set to.

Has anyone managed to export the results of a QueryDefinition to a CSV file and if so what is the correct parameters for a SOAP request?

  • 5
    I respect your optimistic frame of mind, but don't think you're likely to get much joy, here. You can use QueryDefinitions on various types of Data Extension, but they don't write to files. You'd need to run the results to a Data Extension, then to a Data Extension Extract to create a file from the results.
    – Macca
    Oct 7, 2020 at 9:58
  • This is likely an artefact left over from days gone by and is no longer relevant. As the UI and no other place includes this functionality and there is no documentation on this being possible - I would view it as an artefact or perhaps a, at one time, future state option that never came about. Oct 7, 2020 at 12:51
  • Have you contacted SFMC Support to ask about this? They are likely the only ones that can definitively tell you an answer to this. Oct 16, 2020 at 16:36
  • 1
    Have confirmed it is not possible to do it this way. I do not have any official sources to share - but have heard it from some good authorities that whatever this was set up to do originally, it definitely cannot be used to skip the population of a DE and go straight to export. Oct 22, 2020 at 18:46
  • Thanks all was optimistic as this would of saved adding many steps to a data extraction process.
    – colins44
    Oct 23, 2020 at 4:08

1 Answer 1


What I have done in the past is to run the query through an SQL Activity instead of run it directly. The process is somehting like this:

  1. Create a Query activity
  2. Use the SOAP API to perform the SQL Activity
  3. Wait as much as needed till the query finishes... This is something you need to estimate outside SFMC
  4. The data have to be prepared over a DE, you can use several different methods to extract the Data.

And this is basically what @Macca is briefly explaining on his comment.

You must log in to answer this question.

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