Im having trouble creating a filter with Gmail API using node. Auth and scopes are fine; I get err "Filter doesn't have any criteria". Im guessing that im doing something wrong with headers / body / Resource Parameter, but cant work it out.
Heres the function, I've tried a number of variants:
function createFilter(auth){
var gmail = google.gmail({version:'v1','auth':auth});
// Create filter rule
var data = {
resource: {
criteria: {
from: "someone@gmail.com"
},
action: {
removeLabelIds: ["INBOX"]
}
},
userId: 'me'
}
// Send rule to Gmail
gmail.users.settings.filters.create(data, function (err, result) {
if (err) {
console.log( err);
} else {
console.log( result );
callback( result );
}
});
};
docs:
Create Filter https://developers.google.com/gmail/api/v1/reference/users/settings/filters/create Filter Resource https://developers.google.com/gmail/api/v1/reference/users/settings/filters#resource Making Requests https://github.com/google/google-api-nodejs-client/#making-authenticated-requests
similar working req in php:
Create a filter using Gmail API
Any help would be so much appreciated!