googleapis / googleapis/google-api-ruby-client
Adsense generate_account_report_csv returns nil due to content_type
- Vorherrschende Sprache
- Ruby
- Sterne
- 2.9k
- Forks
- 888
- Ø Merge
- 6 Min.
- Gemergte PRs (30 T.)
- 218
Beschreibung
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.
```ruby
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
```ruby
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
```
Beitragsleitfaden
Rechercherichtung
Beginne bei Google::Apis::Core::ApiCommand#decode_response_body und verfolge, wie generate_account_report_csv seine text/csv-Antwort verarbeitet. Reproduziere den Aufruf aus dem Issue und überprüfe anschließend, dass die Antwort in einer nutzbaren Form statt als nil zurückgegeben wird, und füge eine Abdeckung für dieses Verhalten hinzu oder führe sie aus.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- ruby
- Bereich
- api
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100