Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adsense generate_account_report_csv returns nil due to content_type #18558

Open
mike-northsail opened this issue Mar 18, 2024 · 0 comments
Open

Comments

@mike-northsail
Copy link

In Google::Apis::Core::ApiCommand#decode_response_body it checks to see if the content_type starts with JSON_CONTENT_TYPE. The content type comes back as text/csv so it has an explicit return of nil.

        def decode_response_body(content_type, body)
          return super unless response_representation
          return super if options && options.skip_deserialization
          return super if content_type.nil?

         # HERE content_type = "text/csv" when making a generate_account_report_csv request so it returns nil
          return nil unless content_type.start_with?(JSON_CONTENT_TYPE)
          body = "{}" if body.empty?
          instance = response_class.new
          response_representation.new(instance).from_json(body, unwrap: response_class)
          instance
        end

Environment details

  • OS: Ubuntu 20.04
  • Ruby version: 3.2.2
  • Gem name and version: google-apis-adsense_v2 / 0.31.0

Steps to reproduce

Make a call to generate_account_report_csv

Code example

  sense = Google::Apis::AdsenseV2::AdsenseService.new
  scope = ['https://www.googleapis.com/auth/adsense']
  sense.authorization = Google::Auth::ServiceAccountCredentials.make_creds(
    json_key_io: File.open('./account.json'),
    scope: scope
  )
  account = "accounts/pub-xxxxxxxxxxxxx"
  result = sense.generate_account_report_csv(
    account,
    date_range: 'YESTERDAY',
    dimensions: %w[DATE],
    metrics: %w[PAGE_VIEWS IMPRESSIONS CLICKS]
  )

  pp result # will be nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant