googleapis / google-api-dotnet-client

Google APIs Client Library for .NET
https://developers.google.com/api-client-library/dotnet
Apache License 2.0
1.35k stars 526 forks source link

Issue with Metrics in DBM Reach Report #1656

Closed ASHWINI-GUPTA closed 4 years ago

ASHWINI-GUPTA commented 4 years ago

I was trying to create the reach report using Create Query call - https://developers.google.com/bid-manager/v1.1/queries/createquery using SDK, getting below error response from API.

Exception thrown: 'Google.GoogleApiException' in System.Private.CoreLib.dll: 'Google.Apis.Requests.RequestError
The request you submitted is invalid. [400]
Errors [
    Message[The request you submitted is invalid.] Location[ - ] Reason[validationError] Domain[global]
]'

When I checked DV360 UI I'm able to see the newly created Reach Report but it did not contain any Metrics provided -

Metrics = new[]
{
    "METRIC_UNIQUE_REACH_IMPRESSION_REACH",
    "METRIC_UNIQUE_REACH_CLICK_REACH",
    "METRIC_UNIQUE_REACH_TOTAL_REACH",
    "METRIC_UNIQUE_REACH_AVERAGE_IMPRESSION_FREQUENCY"
},

image

I also try to pull the Reach report created on DV360 Platform to check the correct metric name, getting metrics name as "METRIC_UNKNOWN" for all Reach metrics selected in Report -

    "metrics": [
      "METRIC_UNKNOWN",
      "METRIC_UNKNOWN",
      "METRIC_UNKNOWN",
      "METRIC_UNKNOWN"
    ],

Complete Response

{
  "kind": "doubleclickbidmanager#query",
  "metadata": {
    "dataRange": "MONTH_TO_DATE",
    "format": "CSV",
    "googleCloudStoragePathForLatestReport": "URL", // Changed
    "googleDrivePathForLatestReport": "",
    "latestReportRunTimeMs": 1600245611669,
    "locale": null,
    "reportCount": 0,
    "running": false,
    "sendNotification": false,
    "shareEmailAddress": null,
    "title": "Reach Report",
    "ETag": null
  },
  "params": {
    "filters": [
      {
        "type": "FILTER_ADVERTISER",
        "value": "",
        "ETag": null
      }
    ],
    "groupBys": [
      "FILTER_PARTNER",
      "FILTER_COUNTRY",
      "FILTER_ADVERTISER",
      "FILTER_INSERTION_ORDER",
      "FILTER_LINE_ITEM"
    ],
    "includeInviteData": true,
    "metrics": [
      "METRIC_UNKNOWN",
      "METRIC_UNKNOWN",
      "METRIC_UNKNOWN",
      "METRIC_UNKNOWN"
    ],
    "type": "TYPE_REACH_AND_FREQUENCY",
    "ETag": null
  },
  "queryId": 00000000, // Changed
  "reportDataEndTimeMs": null,
  "reportDataStartTimeMs": null,
  "schedule": {
    "endTimeMs": 0,
    "frequency": "ONE_TIME",
    "nextRunMinuteOfDay": null,
    "nextRunTimezoneCode": null,
    "ETag": null
  },
  "timezoneCode": null,
  "ETag": "\"ZelHb3Dp5JnMm78yZe-j6LnxBf82VZ-LV3xEnzr3lKI/mBvRfmYNCusbE4gfmmRMz5Gwkkg\""
}

Referring this doc for metric naming - https://developers.google.com/bid-manager/v1.1/filters-metrics#metrics

Using the below Query object for creating new Reach report -

return new Query
{
    Kind = "doubleclickbidmanager#query",
    Metadata = new QueryMetadata
    {
        Title = "AG - DBM Reach API",
        DataRange = "LAST_7_DAYS",
        Format = "CSV",
        SendNotification = false
    },
    Params__ = new Parameters
    {
        Type = "TYPE_REACH_AND_FREQUENCY",
        GroupBys = new[]
        {
            "FILTER_PARTNER",
            "FILTER_COUNTRY",
            "FILTER_ADVERTISER",
            "FILTER_INSERTION_ORDER",
            "FILTER_LINE_ITEM"
        },
        Filters = new List<FilterPair>
        {
            new FilterPair
            {
                Type = "FILTER_ADVERTISER",
                Value = ""
            }
        },
        Metrics = new[]
        {
            "METRIC_UNIQUE_REACH_IMPRESSION_REACH",
            "METRIC_UNIQUE_REACH_CLICK_REACH",
            "METRIC_UNIQUE_REACH_TOTAL_REACH",
            "METRIC_UNIQUE_REACH_AVERAGE_IMPRESSION_FREQUENCY"
        },
        IncludeInviteData = true
    },
    Schedule = new QuerySchedule
    {
        Frequency = "ONE_TIME",
        EndTimeMs = 0
    }
};
amanda-tarafa commented 4 years ago

@ASHWINI-GUPTA this seems more like an issue with the API or something missing in your request than with the client library itself. When you try this same query on the API Explorer (where it says Try this API on the following image), what result do you get? If it fails there as well, then the issue you are seing is not related to the client library and I would recommend in that case that you explore this Support resources.

Please take into account that the maintainers of this repo are not experts in the APIs themselves (this repo has client libraries for over 100 APIs) but only on the client libraries themselves.

ASHWINI-GUPTA commented 4 years ago

@amanda-tarafa seems like some issue with SDK only, tried using "Try this API" got the 200 Response.

image

Response data -

{
  "kind": "doubleclickbidmanager#query",
  "queryId": "733180910",
  "metadata": {
    "title": "AG - DBM Reach API - Try Now",
    "dataRange": "LAST_7_DAYS",
    "format": "CSV",
    "running": true,
    "sendNotification": false
  },
  "params": {
    "type": "TYPE_REACH_AND_FREQUENCY",
    "groupBys": [
      "FILTER_PARTNER",
      "FILTER_COUNTRY",
      "FILTER_ADVERTISER",
      "FILTER_INSERTION_ORDER",
      "FILTER_LINE_ITEM"
    ],
    "filters": [
      {
        "type": "FILTER_ADVERTISER",
        "value": ""
      }
    ],
    "metrics": [
      "METRIC_UNIQUE_REACH_IMPRESSION_REACH",
      "METRIC_UNIQUE_REACH_CLICK_REACH",
      "METRIC_UNIQUE_REACH_TOTAL_REACH",
      "METRIC_UNIQUE_REACH_AVERAGE_IMPRESSION_FREQUENCY"
    ]
  },
  "schedule": {
    "frequency": "ONE_TIME"
  }
}

Request data -

{
  "kind": "doubleclickbidmanager#query",
  "metadata": {
    "dataRange": "LAST_7_DAYS",
    "format": "CSV",
    "sendNotification": false,
    "title": "AG - DBM Reach API - Try Now"
  },
  "params": {
    "filters": [
      {
        "type": "FILTER_ADVERTISER",
        "value": ""
      }
    ],
    "groupBys": [
      "FILTER_PARTNER",
      "FILTER_COUNTRY",
      "FILTER_ADVERTISER",
      "FILTER_INSERTION_ORDER",
      "FILTER_LINE_ITEM"
    ],
    "includeInviteData": true,
    "metrics": [
      "METRIC_UNIQUE_REACH_IMPRESSION_REACH",
      "METRIC_UNIQUE_REACH_CLICK_REACH",
      "METRIC_UNIQUE_REACH_TOTAL_REACH",
      "METRIC_UNIQUE_REACH_AVERAGE_IMPRESSION_FREQUENCY"
    ],
    "type": "TYPE_REACH_AND_FREQUENCY"
  },
  "schedule": {
    "endTimeMs": 0,
    "frequency": "ONE_TIME"
  }
}

Tried pulling this created report using queryId using SDK got response with "METRIC_UNKNOWN" -

{
  "kind": "doubleclickbidmanager#query",
  "metadata": {
    "dataRange": "LAST_7_DAYS",
    "format": "CSV",
    "googleCloudStoragePathForLatestReport": "",
    "googleDrivePathForLatestReport": "",
    "latestReportRunTimeMs": 1600764466093,
    "locale": null,
    "reportCount": 0,
    "running": false,
    "sendNotification": false,
    "shareEmailAddress": null,
    "title": "AG - DBM Reach API - Try Now",
    "ETag": null
  },
  "params": {
    "filters": [
      {
        "type": "FILTER_ADVERTISER",
        "value": "",
        "ETag": null
      }
    ],
    "groupBys": [
      "FILTER_PARTNER",
      "FILTER_COUNTRY",
      "FILTER_ADVERTISER",
      "FILTER_INSERTION_ORDER",
      "FILTER_LINE_ITEM"
    ],
    "includeInviteData": true,
    "metrics": [
      "METRIC_UNKNOWN",
      "METRIC_UNKNOWN",
      "METRIC_UNKNOWN",
      "METRIC_UNKNOWN"
    ],
    "type": "TYPE_REACH_AND_FREQUENCY",
    "ETag": null
  },
  "queryId": 733180910,
  "reportDataEndTimeMs": null,
  "reportDataStartTimeMs": null,
  "schedule": {
    "endTimeMs": 0,
    "frequency": "ONE_TIME",
    "nextRunMinuteOfDay": null,
    "nextRunTimezoneCode": null,
    "ETag": null
  },
  "timezoneCode": null,
  "ETag": "\"ZelHb3Dp5JnMm78yZe-j6LnxBf82VZ-LV3xEnzr3lKI/0Y3RGWpZ6WayL-BXCdUlFeR5exw\""
}
amanda-tarafa commented 4 years ago

Thanks, I'll take a look later this week.

amanda-tarafa commented 4 years ago

I haven't been able to reproduce this, but will try again at the end of the week.

ASHWINI-GUPTA commented 4 years ago

Hey @amanda-tarafa, able to reproduce the issue?

amanda-tarafa commented 4 years ago

Hi @ASHWINI-GUPTA not yet, I'm having to set up a DBM account and that's been requiring a little more work than I expected. But I'm still trying to reproduce, and will get there eventually, I'm working on this in between some other things.

Take into account that as the maintainers of this repo, we are not experts in each of the individual APIs or products, but only on the client libraries themselves, making sure that they accurately reflect what the corresponding API offers. So an issue like this, which seems to be client library related but also product specific, it's a little harder than usual for us to diagnose.

But again, I'm working on it and will get back here as soon as I have more info, probably early next week.

amanda-tarafa commented 4 years ago

@ASHWINI-GUPTA I'm looking at this now, I'll report back as soon as I know what's happening.

amanda-tarafa commented 4 years ago

@ASHWINI-GUPTA I've been able to reproduce this issue and I think I know what the problem is. I believe you are using Google.Apis.DoubleClickBidManager.v1 but you should be using Google.Apis.DoubleClickBidManager.v1_1. The metrics you are using don't exist in DoubleClikc Bid Manager v1 (which is being deprecated) but only on DoubleClikc Bid Manager v1.1. Everything should work as expected if you use Google.Apis.DoubleClickBidManager.v1_1, it just worked for me. If I use Google.Apis.DoubleClickBidManager.v1 I can reproduce what you are seing.

ASHWINI-GUPTA commented 4 years ago

Hey @amanda-tarafa, You are correct i was using the v1 package instead of v1_1, updating to v1_1 has resolved the issue. Thanks a lot 😇.

amanda-tarafa commented 4 years ago

Happy that it worked! Closing now.