【问题标题】:Upload a list of customers email to Google Ads Management API将客户电子邮件列表上传到 Google Ads Management API
【发布时间】:2019-04-24 21:58:43
【问题描述】:

我正在尝试使用this 指南上传客户散列电子邮件列表,这是我的代码。

File file = new File("/customerMatchHashed.csv");
InputStreamContent mediaContent = new InputStreamContent("application/octet-stream",
    new FileInputStream(file));
mediaContent.setLength(file.length());

try {
  Analytics analytics = initializeAnalytics();
  analytics.management().uploads().uploadData("AccountIdHere",
      "UA-123456-1", "1223334444", mediaContent).execute();
} catch (GoogleJsonResponseException e) {
  System.err.println("There was a service error: "
      +  e.getDetails().getCode() + " : "
      +  e.getDetails().getMessage());
}

我一直遇到这个错误。

出现服务错误:400 : Invalid custom data source ID format: xxxxx.

错误是不言自明的,但我不知道从哪里得到这个custom data source ID(它应该是一个字符串),因为我在 Google Analytics 控制台中看不到任何这样的东西。同样,web property Id,也是一个字符串,但我在控制台中看不到它。 对于从何处获取这两个属性的任何帮助/指导,我将不胜感激。

【问题讨论】:

  • 我认为你应该做一个list 来取回正确的ID。
  • 嗨@DaImTo,它仍然需要webPropertyId。 CustomDataSources 来源 = analytics.management()。 customDataSources().list("accountId", "webPropertyId").execute(); com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request { "code" : 400, "message" : "无效的客户端数据:无效的参数:找不到属性 。” }
  • 那么您的帐户和网络属性 ID 错误,请执行 accountSummaries.list 并找到您要查找的帐户 ID 和网络属性 ID。

标签: java google-api google-analytics-api google-api-java-client


【解决方案1】:

您应该做的第一件事是accountSummaries.list。这将为您提供当前经过身份验证的用户有权访问的所有帐户的列表。

AccountSummaries accountSummaries = service.management().accountSummaries().list().execute();

然后,一旦您在 Google Analytics(分析)管理部分中设置了 data import 的网络媒体资源中找到了该帐户。您可以运行custom data sources list,它将返回为该帐户设置的所有自定义数据源。

CustomDataSources sources = analytics.management().customDataSources().list(AccountIdFromPreviousRequest, WebpropertyIdFromPreviousReqeust).execute();

然后您可以使用上传中返回的 id

analytics.management().uploads().uploadData(AccountIdFromFirstRequest,
                                            WebpropertyIdFromFirstReqeust,                                                
                                           customDataSourcesFromPrevousRequest,
                                           mediaContent).execute();

【讨论】:

  • 总比没有好,感谢您抽出宝贵的时间。我最终从 Big Query 中读取了数据,而这个问题并没有在那里重现。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-10-05
  • 2021-05-25
  • 2014-04-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多