1

Using the ExactTarget API, I'm trying to get all the properties for a QueryDefinition. I have them all, but when I try to get the "DataExtensionTarget" property, I get the folowing error message:

"Error: The Request Property(s) DataExtensionTarget do not match with the fields of QueryDefinition retrieve"

Is this property not available to retrieve via the API?

Here is my code:

var retrieveRequest = new RetrieveRequest();
retrieveRequest.ObjectType = "QueryDefinition";
retrieveRequest.Properties = new string[] { "CategoryID", "ObjectID", "CustomerKey", "Name", "Description", "QueryText", "TargetType", "TargetUpdateType", "Status", "FileSpec", "FileType", "DataExtensionTarget" };

string requestID;
APIObject[] results;
var status = this.client.Retrieve(retrieveRequest, out requestID, out results);
2

I made a guess and figured out the solution to this. In order to access the properties of the associated data extension, you must dot notation and get the data extension properties individually. See my updated code below and notice the references to "DataExtensionTarget.Name", "DataExtensionTarget.CustomerKey" and "DataExtensionTarget.Description".

var retrieveRequest = new RetrieveRequest();
retrieveRequest.ObjectType = "QueryDefinition";

retrieveRequest.Properties = new[] { "CategoryID", "ObjectID", "CustomerKey", "Name", "Description", "QueryText", "TargetType", "TargetUpdateType", "Status", "FileSpec", "FileType", "DataExtensionTarget.Name", "DataExtensionTarget.CustomerKey", "DataExtensionTarget.Description" };

string requestID;
APIObject[] results;
var status = this.client.Retrieve(retrieveRequest, out requestID, out results);

Then you can get the data extension name by using something like the code below:

((QueryDefinition)results[0]).DataExtensionTarget.Name

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.