I am trying to create / Update Query Definition using SSJS WSProxy method.

This is my script:

<script runat="server" >

  var api=new Script.Util.WSProxy();

  var qd = {
    Name : "WS_Created_Query",
    CustomerKey : "myQueryDef124579",
    TargetUpdateType : "Overwrite",
    TargetType : "DE",
    Target : {
        Name : "Counts",
        CustomerKey : "Counts-Key"
    QueryText : "SELECT * from errorlog"

var myDE=api.createItem("QueryDefinition",qd);


but this Script not working.. can someone helps to identify the error, please. (I have a feeling QueryDefinition is not the correct object name for this method.?)


1 Answer 1


QueryDefinition is the correct object for this. However, "Target" is not a property of the QueryDefinition object of the SOAP API. So if you'd just go ahead and replace "Target" with "DataExtensionTarget", that should resolve it.

  • This is incorrect, you should be using "Target"
    – Brett
    Dec 11, 2019 at 3:41
  • 2
    Look at the SOAP API object for Query Definition. Target is not a property, but DataExtensionTarget is. Mar 30, 2020 at 2:06

You must log in to answer this question.

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