google-api-nodejs-client icon indicating copy to clipboard operation
google-api-nodejs-client copied to clipboard

doubleclickbidmanager createquery ignoring params

Open sello-rex opened this issue 7 years ago • 3 comments

I am trying to create a query however I don't seem to be getting the expected response, I have the following code

let display360 = google.doubleclickbidmanager({
    version: "v1",
    auth: oauth2Client
});

let advertisersParams = {
    "metadata": {
        "dataRange": "LAST_90_DAYS",
        "title": "Advertisers List",
        "sendNotification": false,
    },
    "params": {
        "type": "TYPE_GENERAL",
        "filters":[{
            "type": "FILTER_PARTNER",
            "value": "xxxxxxx"
        }],
        "includeInviteData": false,
        "groupBys": ["FILTER_ADVERTISER"],
        "metrics": ["METRIC_IMPRESSIONS"]
    },
    "schedule": {
        "frequency": "ONE_TIME"
    }
};

display360.queries.createquery(advertisersParams, function(error, response){

    if(error){
        console.log(error)
    }

    if(response){
       console.log(response)
    }
});

The above code should create a query but I get an error reporting that metadata, params, and schedule are required even though I have passed an object advertisersParams with those field, the same object I've used on Google API Explorer and it works, i assumed the object should be the same on api call but they don't seem to be taken by the api, taking a look at the request error, the request.path does contain the params as /doubleclickbidmanager/v1/query?kind=doubleclickbidmanager#query&metadata[dataRange]=LAST_90_DAYS&metadata[title]=Advertisers List&metadata[sendNotification]=false&params[type]=TYPE_GENERAL&params[filters][type]=FILTER_PARTNER&params[filters][value]=3236833&params[groupBys]=FILTER_ADVERTISER&params[metrics]=METRIC_IMPRESSIONS&schedule[frequency]=ONE_TIME, so how is it that they are included but still tells me they are not there, or am i passing these params incorrectly?

sello-rex avatar Dec 21 '18 08:12 sello-rex

👋 This is admittedly confusing. The API is looking for your params to be wrapped in a requestBody object:

let advertisersParams = {
    "metadata": {
        "dataRange": "LAST_90_DAYS",
        "title": "Advertisers List",
        "sendNotification": false,
    },
    "params": {
        "type": "TYPE_GENERAL",
        "filters":[{
            "type": "FILTER_PARTNER",
            "value": "xxxxxxx"
        }],
        "includeInviteData": false,
        "groupBys": ["FILTER_ADVERTISER"],
        "metrics": ["METRIC_IMPRESSIONS"]
    },
    "schedule": {
        "frequency": "ONE_TIME"
    }
};
let request = {
  requestBody: advertisersParams
};
display360.queries.createquery(requestBody, ....

Can you give this a shot? Hope this helps!

JustinBeckwith avatar Dec 23 '18 04:12 JustinBeckwith

This is admittedly confusing. The API is looking for your params to be wrapped in a requestBody object:

let advertisersParams = {
    "metadata": {
        "dataRange": "LAST_90_DAYS",
        "title": "Advertisers List",
        "sendNotification": false,
    },
    "params": {
        "type": "TYPE_GENERAL",
        "filters":[{
            "type": "FILTER_PARTNER",
            "value": "xxxxxxx"
        }],
        "includeInviteData": false,
        "groupBys": ["FILTER_ADVERTISER"],
        "metrics": ["METRIC_IMPRESSIONS"]
    },
    "schedule": {
        "frequency": "ONE_TIME"
    }
};
let request = {
  requestBody: advertisersParams
};
display360.queries.createquery(requestBody, ....

Can you give this a shot? Hope this helps!

That helped @JustinBeckwith, thank you very much, it was very confusing.

sello-rex avatar Dec 26 '18 11:12 sello-rex

Great to hear you're on the right track!

JustinBeckwith avatar Dec 26 '18 16:12 JustinBeckwith