doubleclickbidmanager createquery ignoring params
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¶ms[type]=TYPE_GENERAL¶ms[filters][type]=FILTER_PARTNER¶ms[filters][value]=3236833¶ms[groupBys]=FILTER_ADVERTISER¶ms[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?
👋 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!
This is admittedly confusing. The API is looking for your params to be wrapped in a
requestBodyobject: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.
Great to hear you're on the right track!