无法使用Google Adwords API将谓词添加到选择器 [英] Not able to add predicate to selector with Google Adwords API

查看:49
本文介绍了无法使用Google Adwords API将谓词添加到选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google Adwords API版本-201603

I am using Google Adwords API version - 201603

在生成标准"报告时,我正在使用谓词过滤数据. 这是我要在选择器中添加谓词以过滤数据的代码.

While generating Criteria report, I am filtering the data using predicate. Here is the code where I am adding predicate to the selector to filter the data.

final Selector selector = new Selector();
selector.getFields().addAll(Lists.newArrayList("CampaignId",
    "AdGroupId",
    "Id",
    "CriteriaType",
    "Criteria",
    "FinalUrls",
    "Impressions",
    "Clicks",
    "Cost"));

final Predicate p=new Predicate();
p.setField("CriteriaType");
p.setOperator(PredicateOperator.CONTAINS_ANY);
p.getValues().add("Webpage");
final Collection<Predicate> predicates=new ArrayList<>();
predicates.add(p);
selector.getPredicates().add(p);

但是当我运行代码时,我遇到了错误.

But when i run the code, I am getting below error.

       __rdxml: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><reportDefinition xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201603"><ns2:selector><ns2:fields>CampaignId</ns2:fields><ns2:fields>AdGroupId</ns2:fields><ns2:fields>Id</ns2:fields><ns2:fields>CriteriaType</ns2:fields><ns2:fields>Criteria</ns2:fields><ns2:fields>FinalUrls</ns2:fields><ns2:fields>Impressions</ns2:fields><ns2:fields>Clicks</ns2:fields><ns2:fields>Cost</ns2:fields><ns2:predicates><ns2:field>CriteriaType</ns2:field><ns2:operator>CONTAINS_ANY</ns2:operator><ns2:values>Webpage</ns2:values></ns2:predicates></ns2:selector><ns2:reportName>Criteria performance report #1467042784488</ns2:reportName><ns2:reportType>CRITERIA_PERFORMANCE_REPORT</ns2:reportType><ns2:dateRangeType>ALL_TIME</ns2:dateRangeType><ns2:downloadFormat>CSV</ns2:downloadFormat></reportDefinition>

[27 Jun 2016 11:53:04,876-report_download:WARN:main] Response received with status code 400 and message: Bad Request

Report was not downloaded due to: HTTP Response Code: 400, FieldPath: selector, Trigger: CriteriaType, Type: SelectorError.INVALID_PREDICATE_OPERATOR

我无法弄清楚是什么错误.如果有人知道发生了什么.请回答问题.

I am not able to figure out what is the error. If anyone has idea about what is going on. Please do answer the question.

推荐答案

根据Adwords API小组的成员,该运算符只能与标签一起使用.

看到您的谓词中只有一个值,您难道不能只使用CONTAINS而不是CONTAINS_ANY吗?

Seeing as you only have a single value in your predicate, couldn't you just use CONTAINS instead of CONTAINS_ANY?

这篇关于无法使用Google Adwords API将谓词添加到选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆