googleapis / googleapis/google-api-ruby-client

Adsense generate_account_report_csv returns nil due to content_type

Aperta
#18,558 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Ruby
Stelle
2.9k
Fork
888
Merge medio
6m
PR unite (30g)
218

Descrizione

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

```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start at Google::Apis::Core::ApiCommand#decode_response_body and trace how generate_account_report_csv handles its text/csv response. Reproduce the call from the issue, then verify that the response is returned in a usable form instead of nil and add or run coverage for this behavior.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
ruby
Ambito
api
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.