Search code examples
c#.netsoapexacttargetsalesforce-marketing-cloud

How to execute a SQL query against Salesforce marketing cloud using SOAP API?


I am a new SOAP API user trying to access Salesforce marketin cloud. My requirement is to execute a query to pull records from the _Job dataview present in salesforce marketing cloud as below:

select * from _Job

The SOAP API documentation has the following method available.

System.String query = Query(QueryRequest, RequestID, Results)

I did not find any sample code to build the QueryRequest. Please help me creating the QueryRequest and executing it.

Additionally the following link describes how to create and perform a query using QueryDefinition Object here:

https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/creating_a_query_activity.htm

How do I define the TargetType for QueryDefinition? The example uses a value DE and executes the query to populate a data extension. What other values can be specified and used. For instance, is there a value to export the result to a file? If yes, how do I achieve that?

Thanks in advance.


Solution

  • The system views (prefixed with underscore) aren't available to the API. I would suggest you create a data extension that is Select * from _Send and then run the api against that DE.