dotNet Google DoubleClickBidManager API createQuery не удалось - PullRequest
0 голосов
/ 11 декабря 2018

Ошибка возникает в qrt.execute ().У кого-нибудь есть рабочая логика кода в C # или vb.net?Я спросил dbmapi-support@google.com, и они попросили, чтобы я отправил им все тело запроса JSON.Вы знаете, как это увидеть при использовании клиентских библиотек?Я использовал скрипач и не вижу его.Я включил весь код, чтобы увидеть, если я пропускаю ожидаемый параметр.Документация довольно скудная.Код ошибки:

Google.Apis.Requests.Request Error The request you submitted is invalid. [400] Errors [Message[The request you submitted is invalid.] Location[ - ] Reason[validationError] Domainglobal]]

Код:

Dim metrics as string = "METRIC_IMPRESSIONS,METRIC_ACTIVE_VIEW_MEASURABLE_IMPRESSIONS,METRIC_ACTIVE_VIEW_VIEWABLE_IMPRESSIONS,METRIC_CLICKS,METRIC_TOTAL_CONVERSIONS,METRIC_LAST_CLICKS,METRIC_LAST_IMPRESSIONS,METRIC_MEDIA_COST_ADVERTISER"
Dim groupbys as string = "FILTER_DATE,FILTER_ADVERTISER,FILTER_INSERTION_ORDER,FILTER_LINE_ITEM,FILTER_CREATIVE_ID,FILTER_CREATIVE_TYPE,FILTER_DEVICE_TYPE,FILTER_DATA_PROVIDER,FILTER_ADVERTISER_CURRENCY"
dim advertiserId as string = "xxxxxxx"
Dim fileDt As Date = Date.Today()
Dim fileDestination As String = String.Empty
'Authenticate
Dim certificate As New X509Certificate2(path, "notasecret", X509KeyStorageFlags.Exportable Or X509KeyStorageFlags.MachineKeySet)
Dim credential = New ServiceAccountCredential(New ServiceAccountCredential.Initializer(serviceAccountId) With {.Scopes = {Google.Apis.DoubleClickBidManager.v1.DoubleClickBidManagerService.Scope.Doubleclickbidmanager}}.FromCertificate(certificate))
Dim service = New DoubleClickBidManagerService(New BaseClientService.Initializer() With {.HttpClientInitializer = credential, .ApplicationName = "Merkle Cloud Storage"})
Dim startDate As DateTime = DateAdd(DateInterval.Day, -1, Date.Today())
Dim startTime As DateTime = New DateTime(startDate.Year, startDate.Month, startDate.Day, 0, 0, 0)
Dim endTime As DateTime = New DateTime(startDate.Year, startDate.Month, startDate.Day, 23, 59, 59)
Dim qs As QueriesResource = New QueriesResource(service)
Dim body As Query = New Query()
Dim md As QueryMetadata = New QueryMetadata()
  With md
        .DataRange = "PREVIOUS_DAY"
        .Format = "CSV"
        .Title = api_report_name & "-" & startDate.ToString("yyyy-MM-dd")
         .Locale = "en"
  End With
Dim pms As Parameters = New Parameters()
Dim adverts As FilterPair = New FilterPair()
      With adverts
          .Type = "FILTER_ADVERTISER"
          .Value = advertiserId.ToString
       End With
Dim partners As FilterPair = New FilterPair()
      With partners
           .Type = "FILTER_PARTNER"
           .Value = partnerId
      End With
Dim filters As List(Of FilterPair) = New List(Of FilterPair) From {
                    adverts}
                filters.Add(partners)
Dim mets As List(Of String) = New List(Of String)
mets = metrics.Split(",").ToList
Dim gbys As List(Of String) = New List(Of String)
gbys = groupbys.Split(",").ToList
     With pms
          .Filters = filters
          .GroupBys = gbys
          .Metrics = mets
          .Type = "TYPE_GENERAL"
          .IncludeInviteData = False
       End With
Dim qys As QuerySchedule = New QuerySchedule()
      With qys
          .Frequency = "ONE_TIME"
      End With
      With body
          .Metadata = md
          .Params__ = pms
          .Kind = "doubleclickbidmanager#query"
          .Schedule = qys
          .ReportDataStartTimeMs = startTime.Ticks
           .ReportDataEndTimeMs = endTime.Ticks
       End With
Dim qrt As QueriesResource.CreatequeryRequest = qs.Createquery(body)
Dim j = qrt.ToString
Dim qm As Query = qrt.Execute()
Dim queryId As Long = qm.QueryId
...