【问题标题】:GoogleJsonResponseException: API call to dfareporting.ads.insert failed with error: Invalid value at 'profile_id' (TYPE_INT64)GoogleJsonResponseException:对 dfareporting.ads.insert 的 API 调用失败并出现错误:“profile_id”处的值无效(TYPE_INT64)
【发布时间】:2021-08-17 17:37:54
【问题描述】:

我尝试使用以下 ad 对象调用此 API。

  var ad = DoubleClickCampaigns.Ads.insert(6485800,
    {
      
      "campaignId": parseInt(singlePlacementArray[0]),
      "advertiserId": parseInt(inputSheet.getRange("J9").getValue()),
      
      //"accountId": inputSheet.getRange("H9").getValue(),
      "name": singlePlacementArray[1],
       "active": true,
       "archived": false,
      "type": "AD_SERVING_TRACKING",
      "startDate": Utilities.formatDate(singlePlacementArray[5], ss.getSpreadsheetTimeZone(), "yyyy-MM-dd"),
      "endDate": Utilities.formatDate(singlePlacementArray[6], ss.getSpreadsheetTimeZone(), "yyyy-MM-dd"),
      "placementAssignments": [
        {
          "placementId": parseInt(singlePlacementArray[9]),
          "active": true,
          //"sslRequired": false,
        }
      ]
    });

我得到了这个错误,甚至认为 profile_id 是一个 int。

GoogleJsonResponseException: API call to dfareporting.ads.insert failed with error: Invalid value at 'profile_id' (TYPE_INT64), "endDate,2023-06-30,placementAssignments,[Ljava.lang.Object;@7ad1fc95,campaignId,2.2529571E7,type,AD_SERVING_TRACKING,active,true,startDate,2021-05-29,advertiserId,6334010.0,name,video campaign test parallel tracking_cn+Video,archived,false"

【问题讨论】:

    标签: google-apps-script double-click-advertising google-apps-script-api


    【解决方案1】:

    看来DoubleClickCampaigns.Ads.insert的方法的参数是DoubleClickCampaigns.Ads.insert(object, profileId)。我认为您的问题的原因可能是由于这个。而且,似乎profileIdstring (int64 format)。那么下面的修改呢?

    修改脚本:

    var ad = DoubleClickCampaigns.Ads.insert({
      "campaignId": parseInt(singlePlacementArray[0]),
      "advertiserId": parseInt(inputSheet.getRange("J9").getValue()),
      //"accountId": inputSheet.getRange("H9").getValue(),
      "name": singlePlacementArray[1],
      "active": true,
      "archived": false,
      "type": "AD_SERVING_TRACKING",
      "startDate": Utilities.formatDate(singlePlacementArray[5], ss.getSpreadsheetTimeZone(), "yyyy-MM-dd"),
      "endDate": Utilities.formatDate(singlePlacementArray[6], ss.getSpreadsheetTimeZone(), "yyyy-MM-dd"),
      "placementAssignments": [
        {
          "placementId": parseInt(singlePlacementArray[9]),
          "active": true,
          //"sslRequired": false,
        }
      ]
    }, "6485800");
    

    注意:

    • 在这个修改后的脚本中,它假设您在第一个参数的对象中的值和第二个参数的profileId 的值是有效值。请注意这一点。
    • 来自the official document,我不确定是否可以在此请求中使用startDateendDate。是startTimeendTime 吗?如果出现错误,请再次检查。

    参考资料:

    【讨论】:

    • 谢谢,但是你怎么知道 profileId 是第二个参数?文档说:The request body contains an instance of Ad.
    • @Elad Benda 感谢您的回复。关于how do you know the profileId is the second arg?的问题,在这种情况下,您可以在insert(resource: Dfareporting_v3_4.Dfareporting.V3_4.Schema.Ad, profileId: string)等脚本编辑器的自动完成中看到它。
    • 我改变了,现在我得到一个无法解释的错误:Unexpected error while getting the method or property insert on object Apiary.dfareporting.ads. 知道如何让它更清晰吗?
    • @Elad Benda 感谢您的回复。关于您的新问题,虽然我认为这是由于第一个参数的对象,但不幸的是,我无法从您的错误消息中了解它的细节。我为此道歉。在这种情况下,我想建议将其作为新问题发布。因为我的回答是针对您的第一个问题。我深表歉意,我无法解决您的所有问题。这是因为我的技术不好。我再次为此深表歉意。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-17
    相关资源
    最近更新 更多